Skip to content Skip to sidebar Skip to footer

Appending Html With Jquery But Don't Get Style

i am adding some li's with js to my webpage, for this li i use some jquery mobile stylesheets: for loading the js i use this code: $(document).bind('pageshow', function () { Lo

Solution 1:

Look at your < li> definition. It should start with < li>:

<li><ahref="bmw.html">BMW</a></li>

Your formatting is not proper:

<ahref="#"rel="external"><liid="' + element.Identifier + '"><h3>' + element.Naam + '</h3><p>' + element.Adres +  '</p></li></a>

Try to do it as I showed you:

<li><aclass=contacthref="#"id="' + data.response[key].id + '" ><h1>' + data.response[key].label + '</h1><p>'+ data.response[key].customer + '</p></a></li>

start with < li> not with href :P In case of problems check this out: jQuery docs. Remember to trigger and then refresh the list:

$('.greenfluxlist').trigger('create');
$('.greenfluxlist').listview('refresh');

Solution 2:

Try to add something like this:

$('.greenfluxlist').listview('refresh');

I can provide you an example. First appending function:

functionsuccess(data)
            {
                var html ='';
                $.each(data.response, function(key, value) {
                html += '<li><a class=contact href="#" id="' + data.response[key].id + '" ><h1>' + data.response[key].label + '</h1><p>'+ data.response[key].customer + '</p></a></li>';
                $('#contact_listview').append($(html));
                html='';
                });
                $('#contact_listview').trigger('create');    
                $('#contact_listview').listview('refresh');
                $.hidePageLoadingMsg;
            }

And now the html definition:

<ul data-role="listview"id="contact_listview" data-filter="true">

</ul>

Post a Comment for "Appending Html With Jquery But Don't Get Style"