6

我正在研究 Ruby on Rails 教程第 8 章中的示例,并且在我的页面上出现上述错误,并且我的下拉菜单不起作用。关于如何解决这个问题的任何想法?

/* ===================================================
 * bootstrap-transition.js v2.0.0
 * http://twitter.github.com/bootstrap/javascript.html#transitions
 * ===================================================
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ========================================================== */


!function( $ ) {

  $(function () {

    "use strict"

    /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
     * ======================================================= */

    $.support.transition = (function () {
      var thisBody = document.body || document.documentElement
        , thisStyle = thisBody.style
        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined

      return support && {
        end: (function () {
          var transitionEnd = "TransitionEnd"
          if ( $.browser.webkit ) {
Uncaught TypeError: Cannot read property 'webkit' of undefined
            transitionEnd = "webkitTransitionEnd"
          } else if ( $.browser.mozilla ) {
            transitionEnd = "transitionend"
          } else if ( $.browser.opera ) {
            transitionEnd = "oTransitionEnd"
          }
          return transitionEnd
        }())
      }
    })()

  })

}(window.jQuery);
4

2 回答 2

15

我认为这里的问题是:$.browser.webkit- 显然 $.browser 已在 jQuery 1.9+ 中删除。

根据这个线程没有直接替换,但是通过使用这个插件,您应该能够恢复该标签的功能。

于 2013-04-08T08:32:15.900 回答
10

通过使用以下行更新您的 Gemfile 将您的 bootstrap-sass gem 升级到最新版本:

gem 'bootstrap-sass', '~> 2.3.0.1'

我遇到了问题,这是因为我正在运行该 gem 的 2.0.0 版本。不确定他们推荐在教程中运行哪个版本,但升级到最新版本应该不会对您造成伤害。

于 2013-03-08T17:16:03.433 回答