如何在JavaScript弹出模式框的负载下运行波纹管代码?我正在使用facebox。 http://defunkt.io/facebox/
<% content_for :javascript do %>
<script type='text/javascript'>
$(function () {
function InitializeEvents() {
/* new category */
$('#new_admin_category').on('ajax:success', function (event, data, status, xhr) {
$("#dashboard_categories").html(data.html);
InitializeEvents();
});
/* delete category */
$('a[data-remote]').on('ajax:success', function (event, data, status, xhr) {
$("#dashboard_categories").html(data.html);
InitializeEvents();
});
}
InitializeEvents();
})();
</script>
<% end %>
如果您需要更多关于我的代码操作的上下文,请在此处查看上一个问题:Rerun JavaScript on successful ajax call
答案 0 :(得分:0)
解决!实际上真的很简单......我把它从头部移开并留在体内......
<script type='text/javascript'>
$(function () {
function InitializeEvents() {
/* new category */
$('#new_admin_category').on('ajax:success', function (event, data, status, xhr) {
$("#dashboard_categories").html(data.html);
InitializeEvents();
});
/* delete category */
$('a[data-remote]').on('ajax:success', function (event, data, status, xhr) {
$("#dashboard_categories").html(data.html);
InitializeEvents();
});
}
InitializeEvents();
})();
</script>