0

Greeting,

I am trying to replace data-theme but never apply change with trigger.('create') or listview('refresh')

Please test my code at JSFIDDLE

Thank you for your help

Here is my code ...

HTML:

<div data-role="page" id="home">
  <div data-role="content">
    <div>
      <ul id="uuu" data-role="listview">
        <li id="kkk" data-theme="e">fail change to theme A</li>
      </ul>
    </div>
  </div>
</div>

JavaScript :

$('#uuu').append('<li data-theme="a">success change to theme A</li>');

$('#kkk').attr('data-theme', 'a');  // I need do this through ajax

// ======

$('#home').trigger('create');
$("#uuu").listview("refresh");
$("#kkk").listview("refresh"); // this is not working ?
fanartie
  • 1
  • 1
  • what does trigger('create') do? it looks like a custom event. – i-- Jan 18 '13 at 22:09
  • It's a jQuery mobile event that when triggered causes the page to get re-rendered. – Kevin B Jan 18 '13 at 22:10
  • http://jquerymobile.com/test/docs/api/events.html - i don't see it. – i-- Jan 18 '13 at 22:11
  • *"it was a"* then. guess that has been removed. – Kevin B Jan 18 '13 at 22:23
  • in any case, i googled and see what you are saying. also i see a duplicate here http://stackoverflow.com/questions/8088837/jquery-mobile-triggercreate-command-not-working – i-- Jan 18 '13 at 22:26
  • Thanks apprentice, the URL you provided is not the same issue, but still thanks for your advice, actually I google a lots and problem not resolved yet. Hope you may help. – fanartie Jan 19 '13 at 07:14

1 Answers1

0

You need to refresh your ul:

$("#uuu").listview("refresh")

for more info: http://jquerymobile.com/demos/1.2.0/docs/lists/lists-methods.html1

ncn corp
  • 113
  • 5
  • I revised my code at http://jsfiddle.net/fanartie/Yz9mc/4/ but apply .listview("refresh") to "kkk" still not working, any idea ? – fanartie Jan 18 '13 at 23:08