需要Jquery协助(Rails 3)
首先,我的Jquery知识非常有限,但我正在阅读和练习来解决这个问题,所以如果这是一个真正的基本问题,请耐心听我说。正如标题所述,我在rails应用程序中收到一条错误消息需要Jquery协助(Rails 3),jquery,ruby-on-rails-3,Jquery,Ruby On Rails 3,首先,我的Jquery知识非常有限,但我正在阅读和练习来解决这个问题,所以如果这是一个真正的基本问题,请耐心听我说。正如标题所述,我在rails应用程序中收到一条错误消息 $(".share a").button is not a function My application.js文件包含以下内容 $(function() { $(".share a") .button() .click(function() { var a = this; // f
$(".share a").button is not a function
My application.js文件包含以下内容
$(function() {
$(".share a")
.button()
.click(function() {
var a = this;
// first set the title of the dialog box to display the folder name
$("#invitation_form").attr("title", "Share '" + $(a).attr("folder_name") + "' with others");
// a hack to display the different folder names correctly
$("#ui-dialog-title-invitation_form").text("Share '" + $(a).attr("folder_name") + "' with others");
// then put the folder_id of the share link into the hidden field "folder_id" of the invite form
$("#folder_id").val($(a).attr("folder_id"));
// the dialog box customization
$("#invitation_form").dialog({
height: 300,
width: 600,
modal: true,
buttons: {
// first button
"Share": function() {
// get the url to post the data to
var post_url = $("#invitation_form form").attr("action");
// serialize the form data and post it the url with ajax
$.post(post_url, $("#invitation_form form").serialize(), null, "script");
return false;
},
// second button
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
}
});
return false;
});
}))
我的视图页面包含了这个调用jquery(我想)
和jquery-ui-1.8.9.custom在我的javascripts中(那里没有其他ui)因为
jquery ui.js
正在加载,但是浏览器javascript引擎找不到函数按钮,问题很可能是因为您正在使用的jquery ui构建中遗漏了“按钮”小部件。您可以通过构建一个包含小部件的新脚本来验证这一点,并使用它代替当前的jqueryui.js
。如果有效,那就是你的答案。你的脚本目录或资产管道中是否列出了多个jquery ui?我已经编辑了我的问题,请查看以回答你的问题。感谢您验证客户端浏览器是否加载了jquery ui?这里的新手问题是,我该怎么做?取决于浏览器。对于firefox,您可以使用firebug插件检查所有脚本。其他浏览器可能有类似的内置功能作为开发工具-谷歌是你的朋友在这里。
<div class="share">
<%= link_to "Share", "#", :folder_id => folder.id, :folder_name => folder.nameunless @is_this_folder_being_shared %>
</div>
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require twitter/bootstrap
//= require_tree .