当点击模式链接时,“b”。preventDefault不是一个函数。

时间:2021-07-25 19:41:55

I am working on Rails with haml format, and I have a table which has in the last column a button (link) that launches a modal:

我正在使用haml格式处理Rails,我有一个表,它在最后一个列中有一个按钮(link),它启动一个模态:

= link_to('#', 'data-toggle' => 'modal', 'data-target' => '#team_modal', 'data-project' => project.id) do %span {
    class: 'glyphicon glyphicon-tasks',
    'aria-hidden' => 'true',
    'aria-hidden' => 'true',
    'data-toggle' => "tooltip",
    'title' => 'Team',
    'data-project' => project.id
}

When I click on it, the modal shows up, then the following error also appears at the console:

当我点击它时,模式出现,然后在控制台出现以下错误:

Uncaught TypeError: b.preventDefault is not a function
 b.hide @ bootstrap.min.js?body=1:7
 b.toggle @ bootstrap.min.js?body=1:7
 (anonymous function) @ bootstrap.min.js?body=1:7
 jQuery.extend.each @ jquery.js?body=1:612
 jQuery.fn.jQuery.each @ jquery.js?body=1:242
 a.fn.modal @ bootstrap.min.js?body=1:7
 (anonymous function) @ bootstrap.min.js?body=1:7
 jQuery.event.dispatch @ jquery.js?body=1:3059
 jQuery.event.add.elemData.handle.eventHandle @ jquery.js?body=1:2677

How can I fix this?

我怎么解决这个问题?

1 个解决方案

#1


0  

After several attempts, finally I removed the duplications like:

经过几次尝试,我终于删除了这样的重复:

config.assets.precompile << "redesign/bootstrap.js

beside this, I removed the pure scripts and kept the minimal scripts, given:

除此之外,我删除了纯脚本,并保留了最小的脚本。

config.assets.precompile << "redesign/bootstrap.css"
config.assets.precompile << "redesign/bootstrap.min.css"
config.assets.precompile << "redesign/bootstrap.js"
config.assets.precompile << "redesign/bootstrap.min.js"

to have this:

有了这个:

config.assets.precompile << "redesign/bootstrap.min.css"
config.assets.precompile << "redesign/bootstrap.min.js"

Note: I don't know what this does but it works. If someone knows why keeping the minimal scripts the error desappear, please comment it.

注意:我不知道这是怎么回事,但它确实有效。如果有人知道为什么要保留最小的脚本错误,请评论一下。

#1


0  

After several attempts, finally I removed the duplications like:

经过几次尝试,我终于删除了这样的重复:

config.assets.precompile << "redesign/bootstrap.js

beside this, I removed the pure scripts and kept the minimal scripts, given:

除此之外,我删除了纯脚本,并保留了最小的脚本。

config.assets.precompile << "redesign/bootstrap.css"
config.assets.precompile << "redesign/bootstrap.min.css"
config.assets.precompile << "redesign/bootstrap.js"
config.assets.precompile << "redesign/bootstrap.min.js"

to have this:

有了这个:

config.assets.precompile << "redesign/bootstrap.min.css"
config.assets.precompile << "redesign/bootstrap.min.js"

Note: I don't know what this does but it works. If someone knows why keeping the minimal scripts the error desappear, please comment it.

注意:我不知道这是怎么回事,但它确实有效。如果有人知道为什么要保留最小的脚本错误,请评论一下。