Reputation: 3214
I have this script called admin_order.js
, which works fine. Due to a certain plugin which loads ajax content after ajax content has been loaded admin_order.js
now doesn't work.
I tried this in the response function but no success.
$.getScript("../../themes/mywebsite/js/admin_order.js");
How do i reload the script?
Upvotes: 2
Views: 12846
Reputation: 30993
I think the problem must be handled in another way; but if you can't handle this in the plugin code, you can:
getScript
remove the script elementgetScript
success function add an Id to the last script elementLike:
<script id="myAdminOrderScript" src="../../themes/mywebsite/js/admin_order.js"></script>
function reloadScript() {
$('#myAdminOrderScript').remove();
$.getScript("../../themes/mywebsite/js/admin_order.js", function() {
$('script:last').attr('id', 'myAdminOrderScript');
});
}
Upvotes: 2