mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-27 21:15:40 +02:00
ENHANCEMENT: SSF-33 Binding the 'cms-link-ajax' class to a javascript function that triggers a CMS ajax method and displays a status message
This commit is contained in:
parent
d2fa232fcd
commit
ee37adbc87
@ -313,4 +313,26 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does an ajax loads of the link's 'href' attribute via ajax and displays any FormResponse messages from the CMS.
|
||||||
|
* Little helper to avoid repetition, and make it easy to trigger actions via a link,
|
||||||
|
* without reloading the page, changing the URL, or loading in any new panel content.
|
||||||
|
*/
|
||||||
|
$('.cms-content .cms-link-ajax').entwine({
|
||||||
|
onclick: function(e) {
|
||||||
|
var href = this.attr('href'), url = href ? href : this.data('href');
|
||||||
|
|
||||||
|
jQuery.ajax({
|
||||||
|
url: url,
|
||||||
|
// Ensure that form view is loaded (rather than whole "Content" template)
|
||||||
|
complete: function(xmlhttp, status) {
|
||||||
|
var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.responseText;
|
||||||
|
if (typeof msg != "undefined" && msg != null) eval(msg);
|
||||||
|
},
|
||||||
|
dataType: 'html'
|
||||||
|
});
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
Loading…
Reference in New Issue
Block a user