In my footer, I wrote this function…
jQuery('#page').live('pageinit', function() {
$('.widget ul').attr('data-inset', 'true');
$('.widget ul').attr('data-theme', 'd');
$('.widget ul').attr('data-dividertheme', 'b');
$('.widget ul').attr('data-role', 'listview');
$('.widget ul').listview();
$('a.post-edit-link').attr('data-inline', 'true');
$('a.post-edit-link').attr('data-role', 'button');
$('a.post-edit-link').button();
$('#commentform').attr('data-theme', 'e'); ...
So, how to apply data-theme on the last line ? What is the method, as ‘listview’ or ‘button’?
I also wonder how to apply ‘widget ul’ to the first attribute…
$(‘.widget ul:first’)
is not working.
Thanks for your help!
Sincerely,
V.
.widget ul:firstwill select the firstulelement that is a descendant of a.widgetelement. If you want to select the first list-item inulthen you need:.widget ul li:first.Forms themselves do not get initialized by jQuery Mobile, so instead of targeting the form, you need to target the specific input widgets and initialize them.
To initialize a bunch of elements you can select them all and call
.trigger('create')on them:This gets slightly trickier when you want to update widgets rather than initialize them:
Also you can optimize your code by chaining function calls rather than re-selecting the same element(s) multiple times:
Or you can pass an object to
.attr()to set all of the attributes in one function call: