我不明白爲什麼我收到以下錯誤: 無法調用「scrollTop的」未定義引導模式:不能調用方法「scrollTop的」未定義
當我點擊,顯示模式的鏈接。
我唱jQuery 1.11,bootstrap 3.1.1。
有關顯示模式的代碼(HAML)
按鈕:
.forgot_password.pull-right = link_to t('.forgot_password'), '#forgot_password', data: { target: "#forgot_password", toggle: "modal" }, tabindex: 5
模態:
#forgot_password.modal{tabindex: -1, role: 'dialog', "aria-labelledby" => t('.title'), "aria-hidden" => true}
.modal-dialog
.modal-content
.modal-header
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
%h4= t('.title')
.modal-body
.form_wrapper
.innertxt= t('.explanation')
.forgot_password_form
= form_for :forgot_password, url: forgot_password_path do |f|
= text_field_tag :email, '', placeholder: t('email'), size: 50, autofocus: true
= submit_tag t('send'), :class => 'btn'
引導其中的問題發生:(方法Modal.prototype 。展示)
this.backdrop(function() {
var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) {
that.$element.appendTo(document.body) // don't move modals dom position
}
that.$element
.show()
.scrollTop(0)
...
顯示的錯誤:
TypeError: 'undefined' is not an object (evaluating 'that.$element
.show()
.scrollTop')
我想這that.element
爲空或未定義,它打破了代碼。但是我正在尋找修補程序/解決方法,因爲它違反了我的測試規範! (紅寶石與水豚)
我跟着http://getbootstrap.com/javascript/#modals的例子,到目前爲止,我沒有看到他們和我的代碼之間的任何區別。我試圖用JavaScript代替html來打開模式,但它完全一樣。
有什麼想法?
編輯:紅寶石/水豚代碼
click_link 'Glemt adgangskode?'# Forgotten password?
sleep 3
within_frame('form_login') do
fill_in 'email', with: '[email protected]'
click_button 'Send'
end
EDIT2:順便說一下,一切正常,該模式彈出正確的,我剛剛得到一個JavaScript錯誤實際上並不影響用法。但我想了解並解決這個問題。