Manuel Alberto Cerdas Salazar on Tue, 27 Nov 2012 21:12:05
Hello: I'm working with the split app template, and I'm having trouble catching an event, specifically when I try to catch when the user clicks a link.
On my split.html I have this
<!--- CODE OMMITTED ---><divclass="article-content"data-win-bind="innerHTML: description"></div>
On my split.js I'm using this code inside the ready function
varcosa = WinJS.Utilities.query("a");
cosa.listen("click",this.navegar,false); //navegar is a function I defined
Any help will be greatly appreciated
Manuel Alberto Cerdas Salazar on Fri, 30 Nov 2012 17:22:50
Seems this thing has something to do with asynchronous programming. Just tried my code with a smaller JSON file and it worked fine.
Cobra Tap on Sat, 01 Dec 2012 22:31:44
Definitely an async timing bug.
You have to figure out when the render function on the template is run and the element is appended to the window.document.
This is exactly why there is the onactivated handler and a promise returned by WinJS.UI.ProcessAll()...
Manuel Alberto Cerdas Salazar on Sun, 02 Dec 2012 05:47:32
Big thank you! Seems I have a lot of reading ahead
Manuel Alberto Cerdas Salazar on Mon, 10 Dec 2012 21:07:43
Got it! Just in case anybody is having the same problem, the event handler has to be placed in the _selectionChanged method located in the split.js file