How to redraw dynamically generated anchor tags in jQuery Mobile?

I get the html shortcut label binding from the server when ajax is called. How to "update" so that jquery mobile can add the necessary classes to links?

For example, the link that jquery mobile generates has a ui-link:

<a class="ui-link" href="http://www.google.com">http://www.google.com</a>

How to ensure that the correct styles are added to the newly created anchor tag?

+5
source share
2 answers

If you want to update a widget that has already been initialized, you can update each view of the widget using the corresponding function:

$('.ui-btn').button('refresh');

, .ui-btn , , , .

: http://jquerymobile.com/demos/1.1.0-rc.1/docs/buttons/buttons-methods.html

, , 'refresh' .trigger('create'):

$('[data-role="button"], button, input[type="button"], input[type="submit"]').not('.ui-btn').button();//or .trigger('create');

, .not('.ui-btn'), . , , ( , , ).

Update

HTML , DOM:

$.ajax({
    ...
    success : function (serverResponse) {
        var $out = $(serverResponse);
        //if there is a container with elements inside it, use `.find()`,
        //if all the elements are siblings at the top level then use `.filter()`
        $out.find('a').button();
        $('body').append($out);
    }
});

.buttonMarkup() : http://jquerymobile.com/demos/1.1.0-rc.1/docs/buttons/buttons-options.html

+1

jQuery Mobile:

$(yourButtons).button('refresh'); 

: http://jquerymobile.com/test/docs/buttons/buttons-types.html

0

All Articles