2

I am using a jqm 1.3 Listview, and I am successfully capturing onClick.

  function handle_onClick( )
    { jQuery( "#my_panel li" )
        .each( function( )
             { jQuery( this ).attr( 'data-theme' , "a" ).trigger('refresh') ;
             }) ;
   } 

see fiddle (EDIT: updated fiddle)

BUT the data-themes of the <li>'s are not being updated.

In practice my <li>'s will not be using the same theme.

Is there a way to pro-grammatically change them, individually?

dsdsdsdsd
  • 2,880
  • 6
  • 41
  • 56
  • What is `gf_Lc_handler__set_li_themes` in your fiddle ? Also where are you wiring up `handle_onClick`? – Nix Mar 07 '13 at 14:20
  • sorry, I saved the fiddle before I changed that ... "gf_Lc_handler__set_li_themes" is supposed to be "handle_onClick" – dsdsdsdsd Mar 07 '13 at 14:55
  • I updated it ... notice how it does not refresh the individual items until you do a mousemove event following the click event. – dsdsdsdsd Mar 07 '13 at 14:58
  • Your fiddle is still not updated. – Gajotres Mar 07 '13 at 15:10
  • You need to click "Set as base" to merge it into the original link. Problem with your code is that it sets every li to the new theme. Take a look at my answer how to do it individually. – Gajotres Mar 07 '13 at 15:17

2 Answers2

1

Here's a working example: http://jsfiddle.net/Gajotres/YNYnU/

$('#my_panel li' ).on( 'click' ,  function( argo_e ) { 
    $(this).attr('data-theme','d');
});

You were using wrong function to enhance listview markup. In this case we don't need to enhance listview markup, setting data-theme attribute to the correct li element is more then enough.

Also take a look at my other answer/article about this topis: https://stackoverflow.com/a/14550417/1848600. Every jQuery Mobile component has a distinct function used to enhance its markup, and every one of them is listed in that article.

And here's example of your code with my fix: http://jsfiddle.net/Gajotres/AeBuV/

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • when I click, the
  • , the theme is not immediately updated, but rather it only updates once I mouseout of the
  • – dsdsdsdsd Mar 07 '13 at 19:23
  • yeah it seems that no matter what I do, the
  • 's do not update their visual appearance until I mouseover/out of them individually ... hmmm
  • – dsdsdsdsd Mar 07 '13 at 19:36
  • On what platform are you testing this? – Gajotres Mar 07 '13 at 19:58
  • it seems that the issue is that, although the theme is being updated, the actual class does not get updated UNTIL a mouseover/out event ... so I am working on that now. – dsdsdsdsd Mar 07 '13 at 20:38
  • Sry I meant what browser are you using. My style updates during the first click. – Gajotres Mar 07 '13 at 20:40