I'm developing a web application using Html5 and jquery. I'm getting this "Error: Syntax error, unrecognized expression: #chapter?book=Exod&num=1
" error when I'm trying to navigate from current page to another page <div data-role="page" id="chapter">
My Code:
$(document).ready(function() {
for (var x in books) {
if (x.indexOf('_')>=0) {
var items = '<li><a href="#chapter?book='+ x.substring(1) +'&num=1">'+ books[x].bname +'</a></li>';
}
$("#book_list").append(items);
}
$('#book_list').find(':jqmData(role=listview)').listview();
});
// Listen for pagebeforechange event
$(document).bind( "pagebeforechange", function( data ) {
// only handle changePage() when loading a page by URL.
if ( typeof data.toPage === "string" ) {
// Handle URLs that requests chapter page
var url = $.mobile.path.parseUrl( data.toPage ), regex = /^#chapter/;
if ( url.hash.search(regex) !== -1 ) {
showChapter( url, data.options );
// tell changePage() we've handled this
//e.preventDefault();
}
}
});
Thanks in Advance.
regex
is correctly escaped?