Mmh really. But there is a .ajaxSuccess() function that runs whenever an Ajax call succeeds. So you can do:
$('body').ajaxSuccess(function() { $('a.btn.plus').button({icons:{primary:'ui-icon-plusthick'}}); $('a.btn.pencil').button({icons:{primary:'ui-icon ui-icon-pencil'}}); $('a.btn.bigx').button({icons:{primary:'ui-icon ui-icon-closethick'}}); });
But this will work on any class links, not just new ones. But if you add them at a specific time (i.e. not several a.btn.plus ), you can use the selector :last ( a.btn.plus:last ).
You can also create a function and only its callback functions:
function links() { $('a.btn.plus').button({icons:{primary:'ui-icon-plusthick'}}); $('a.btn.pencil').button({icons:{primary:'ui-icon ui-icon-pencil'}}); $('a.btn.bigx').button({icons:{primary:'ui-icon ui-icon-closethick'}}); }
and in an Ajax call:
$.ajax({
Thus, you can pass the parent element to the function to find the link only inside this element (therefore, the code will only work with new links).
The last option will generate a custom event, but in the end it will be like just calling a function in your case so you don't get much.
source share