0

如何让波纹管代码在 JavaScript 弹出模式框的负载中运行?我正在使用脸书。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 %>

如果您需要更多关于我的代码正在执行的操作的上下文,请在此处查看上一个问题:在成功的 ajax 调用时重新运行 JavaScript

4

1 回答 1

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>
于 2013-05-14T14:07:57.933 回答