Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导jQuery模式在按钮单击时未加载_Javascript_Jquery_Ruby On Rails_Twitter Bootstrap_Bootstrap Modal - Fatal编程技术网

Javascript 引导jQuery模式在按钮单击时未加载

Javascript 引导jQuery模式在按钮单击时未加载,javascript,jquery,ruby-on-rails,twitter-bootstrap,bootstrap-modal,Javascript,Jquery,Ruby On Rails,Twitter Bootstrap,Bootstrap Modal,我正在为我的Rails 4应用程序使用通过CDN加载的Twitter引导,当点击一个应该加载模式的按钮时,什么都没有发生。如果我试图通过jQuery触发模态,我会得到错误:uncaughttypeerror:undefined不是函数。这是我的密码: .container .row .col-sm-12 %h1 Manage Team .pull-right %a.btn.btn-success#addUserBtn{ data:

我正在为我的Rails 4应用程序使用通过CDN加载的Twitter引导,当点击一个应该加载模式的按钮时,什么都没有发生。如果我试图通过jQuery触发模态,我会得到错误:uncaughttypeerror:undefined不是函数。这是我的密码:

.container
.row
    .col-sm-12
        %h1 Manage Team
        .pull-right
            %a.btn.btn-success#addUserBtn{ data: { toggle: :modal, target: '#new_user' } }
                Add
模态:

#new_user.modal.fade
.modal-dialog
    .modal-content
        .modal-header
            %button.close{ type: :button, 'data-dismiss' => 'modal', 'aria-hidden' => 'true' }
                ×
            %h4.modal-title
                New Agency
        = form_for Agency.new( facilitator_id: current_user.id ) do |f|
            .modal-body
                .form-group
                    = f.label :name
                    = f.text_field :name, class: 'form-control'
                .form-group
                    = f.label :facilitator_id
                    = f.collection_select :facilitator_id, User.admin, :id, :name, {}, class: 'form-control'

            .modal-footer
                %button.btn.btn-default{ type: :button, 'data-dismiss' => 'modal' }
                    Close
                = f.submit 'Create', class: 'btn btn-primary'
jQuery:

$('#addUserBtn').on('click', function() {
    console.log('test');
    $('#new_user').modal('toggle');
}); 

您需要在模式代码中将#new(新)机构.modal.fade更改为#new(新)用户.modal.fade这是一个引导问题。当我使用gems而不是CDN加载引导时,一切正常。谢谢你的帮助。

接得好。改变了,但仍然没有运气。