I have been looking for some answers about this issue on my code and I can't fine different answers because as far as I've seen there are not many answers to this.
I Have a ListView that is being filled with with some server content (note app) I seem able to change selectionMode, tapBehavior and some different properties of the ListView using the WinJS.UI.procesAll().then(//code here);
but the only one that is not working at all though Chrome dev tools tell me there is actually an eventhandler for oninvokeditem but once I click nothing seems to work, any breakpoints I put aren't hit at all.
here's some code:
var WinJSRequest = function (uri, method, data) {
var request = {
url: uri,
type: method,
contentType: "application/json",
accepts: "application/json",
cache: false,
dataType: 'json',
data: JSON.stringify(data),
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization",
"Basic " + btoa(username + ":" + password));
},
error: function (jqXHR) {
//console.log(data);
console.log("ajax error " + jqXHR.status);
}
};
return WinJS.xhr(request).done(
function completed(request) {
var arr = JSON.parse(request.response);
for (var i = 0; i < arr.tareas.length; i++) {
tareas.push(arr.tareas[i]);
}
WinJS.Namespace.define("App.Notas", {
data: new WinJS.Binding.List(tareas)
});
WinJS.UI.processAll().then( function() {
listaTareas = WinJS.Utilities.query('#listaTareas');
listaTareas = listaTareas[0].winControl;
listaTareas.oniteminvoked = function (ev) {
console.log('index: ' + ev.detail.itemIndex);
};
});
},
function error(request) {
alert(request);
},
function progress(request) {
//alert(request);
console.log('In Progress');
});
};
and Here's some HTML
<!-- Template para el Listview -->
<div id="listviewTemplate">
<div class="listViewNotasTemplate" data-win-control="WinJS.Binding.Template">
<div class="listviewItemNota">
<h1 class="win-h1" data-win-bind="textContent: titulo"></h1>
<h3 class="win-h3" data-win-bind="textContent: descripcion"></h3>
<h5 class="win-h5" data-win-bind="textContent: hecho"></h5>
</div>
</div>
</div>
<!-- Codigo del ListView -->
<div id="listaTareas" class="listView win-selectionstylefilled" data-win-control="WinJS.UI.ListView" data-win-options="{
itemDataSource: App.Notas.data.dataSource,
itemTemplate: select('.listViewNotasTemplate'),
selectionMode: 'multi',
tapBehavior:'toggleSelect',
layout: { type: WinJS.UI.ListLayout }
}"></div>
<!-- Termino el ListView -->
<script src="node_modules/winjs/js/base.js"></script>
<script src="node_modules/winjs/js/ui.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="js/index.js"></script>
there's nothing else pretty much that's all the body.
I have tried to use listaTareas.addEventListener('oniteminvoked', handler, false);
,
I tried to declare it on the HTML Control and yet nothing, perhaps is just something I'm not looking help anyone?
Thanks in advance :)
EDIT: for the record as I was looking at the console i found that the oniteminvoked: (...) found this on arguments: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.remoteFunction (:3:14) at Object.InjectedScript.callFunctionOn (:750:66)
There is an error on your event name:
listaTareas.addEventListener('iteminvoked', handler, false)
without 'on' ;)