'0' is null or not an object
I just switched from jquery mobile alpha 2 to jquery mobile beta 1.0. I am using CDN access for the jquery javascript files and the css. I am getting some data from the server a开发者_StackOverflownd displaying it in the list format. I am building list dynamically in the javasript file.
I was using
$('#detail').html(html);
$('#detail ul').listview();
to refresh my list after building it.
It was working well with alpha version of jquery mobile but now without changing a single line of code I am trying to run it using jquery mobile beta and it is breaking with the following error:
Webpage error details
Message: '0' is null or not an object
Line: 133 Char: 183 Code: 0 URI: http://user.mydomain.com/scripts/jquery.mobile-1.0b1.min.js
Am I doing something wrong or some issue with beta version of css file?
EDIT:
I am getting the data in json format (say result object)using ajax call and displaying it like this:
var html = "<ul id="contactDetails" data-role="listview" data-filter="false" data-inset="true">";
html += "<li data-icon='false'><Email:<a href=mailto:'"+ result.Data.email_address_1 + +"'>" + result.Data.email_address_1 + "</a></li>";
html += 'ul close tag'
$('div#page2 div#contentMain div#details ul#customerDetails').html(html)
$('div#page2 div#contentMain div#details ul').listview();
Althought I can see the data coming and displaying properly BUT without the style.
Hope this helps to understand the problem.
Raman
In your examples you are doing
$('div#page2 div#contentMain div#details ul#customerDetails').html(html)
$('div#page2 div#contentMain div#details ul').listview();
But id
s are unique so there is no reason to use multiple id to define the hierarchy..
Just use
$('#customerDetails').html(html);
$('#details ul').listview();
Also make sure you fix your string concatenations .. and that result.Data
contains what you think it does..
I checked this with Jquery Mobile forum and the following solution works for me.
$('#details').html(html)
$('#page2').page();
$('ul#customerDetails').listview('refresh');
精彩评论