我正在使用通过CDN加载我的Rails 4应用程序的Twitter Bootstrap,并且当点击应该加载模式的按钮时,没有任何反应。如果我试图通过jQuery触发模式,我得到的错误:Uncaught TypeError:undefined不是一个函数。这里是我的代码:Bootstrap jQuery莫代尔没有加载按钮点击
.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');
});
好的。改变了这一点,但仍然没有运气。 – 2014-10-10 20:04:01