Hi,
Just would like to confirm that, the search widget is pushing search layer at right level or not ?
because when i try to push a source then it gets added in wrong heirchical level.
var sources = [ { declare only one source } ]
// Add to source(s)
var searchWidget = new Search();
searchWidget.sources.push(sources); //new source
searchWidget.startup();
Then it shows heirchy like
items
[0]
[1]
[0] and here is my source (underneath of [1][0])
I believe my source should be at [1] level of heirchy.
Please correct me if i am missing anything.
Solved! Go to Solution.
You are adding an array and not a source object. Just remove the square brackets from your sources variable declaration.
if the heirchical level is correct then why i m not able to search on added (pushed) sources, whereas when i add the same source at the constructor level of Search() widget then it works perfectly.
Thanks for the solution. (Heirchical level is solved by your response but search issue is still remains)
But the issue remains the same, when i tried to push a source then it won't search on pushed source. and when i assign the same code in the constructor of search() widget then it searches perfectly. I think i am lacking somewhere, let me check once again. or if you have any other clue on that ?
I've constructed my own search sources like this in the past:
sources = searchWidget.get("sources"); sources.push(newsourceobject); //push for adding at the end of the list and unshift to add at the front of the list searchWidget.set("sources", sources); searchWidget.startup();
other way around 🙂
You mean the push/unshift? I'm pretty sure. JavaScript Array unshift() Method