I am getting html from a server dynamically. When a user loads certain html I want to override the functionality of the listview filtering like this:
$("#myList").listview('option', 'filterCallback', function (text, searchValue) {
//console.log(text);
$("li[data-groupoptions]").removeClass('override-ui-screen-hidden');
$("li[data-groupoptions*="+searchValue.toLowerCase()+"]").addClass('override-ui-screen-hidden');
return text.toLowerCase().indexOf( searchValue ) === -1;
});
The problem is when I inject this code into my javascript it breaks all my javascript. I have a syntax issue here or I am not calling this right or something.
I want to add this code to this function I have in place
function loadA() {
ClearDescendant().success(function () {
loadPage("apls", "alData", "alHeader", "alFooter");
//ADD IT HERE????
});
}
How do I simply have this code available to run “in case” there is html on the page with a listview that has an id of “mylist” sometime “loadA()” doesnt return a listview with id “mylist” but the code is simply breaking besides that. I am not sure on how to call or where to put this code so its available when if html is returned from “loadPage()” that has “myList” in it
the code works fine here
http://jsfiddle.net/DCkDp/25/
Does it break when you put the listview declaration inside a load handler function: