我正在使用通過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