I am loading content in using jQuery .load(), within the content that is added are some data- attributes which i want to get the value from to pass into another function.
The .load() code is:
url += ' #post';
$("#modal_base #modal_inner").load(url , function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
$('#error').appendTo( '#modal_inner' );
$("#error").html(msg + xhr.status + " " + xhr.statusText);
}
});
The data- attributes are in #modal_base #modal_inner #post once the content is loaded in.
I presume there is no event for this element i need to somehow attach delegated event handlers to the document element.
What is the best way for me to do get the data-pag-next and data-pag-next values?
The
completecallback will fire once the elements of the retrieved page has been loaded in the destination element and DOM updated, so you just need to look for it: