對於Facebook粉絲頁面我創建了一個靜態html選項卡(https://www.facebook.com/jgsportevents/app_190322544333196),我想要使用鏈接的jquery插件,就像我在客戶端的網站(http://tinyurl.com/c3bfz93)上所做的那樣。鏈式插件位於標籤的基本的script.js,看起來像這樣:用[的script.js]在標籤的index.html文件和jQueryJquery插件不工作在Facebook靜態HTML選項卡
(function($) {
$.fn.chained = function(parent_selector, options) {
return this.each(function() {
/* Save this to self because this changes when scope changes. */
var self = this;
var backup = $(self).clone();
/* Handles maximum two parents now. */
$(parent_selector).each(function() {
$(this).bind("change", function() {
$(self).html(backup.html());
/* If multiple parents build classname like foo\bar. */
var selected = "";
$(parent_selector).each(function() {
selected += "\\" + $(":selected", this).val();
});
selected = selected.substr(1);
/* Also check for first parent without subclassing. */
/* TODO: This should be dynamic and check for each parent */
/* without subclassing. */
var first = $(parent_selector).first();
var selected_first = $(":selected", first).val();
$("option", self).each(function() {
/* Remove unneeded items but save the default value. */
if (!$(this).hasClass(selected) &&
!$(this).hasClass(selected_first) && $(this).val() !== "") {
$(this).remove();
}
});
/* If we have only the default value disable select. */
if (1 == $("option", self).size() && $(self).val() === "") {
$(self).attr("disabled", "disabled");
} else {
$(self).removeAttr("disabled");
}
$(self).trigger("change");
});
/* Force IE to see something selected on first page load, */
/* unless something is already selected */
if (!$("option:selected", this).length) {
$("option", this).first().attr("selected", "selected");
}
/* Force updating the children. */
$(this).trigger("change");
});
});
};
/* Alias for those who like to use more English like syntax. */
$.fn.chainedTo = $.fn.chained;
})(jQuery);
$("#bestemming").chained("#sport"); /* or $("#series").chainedTo("#mark"); */// Javascript Document
而且我打電話選項卡的腳本頁面與http://code.jquery.com/jquery-latest.min.js'>。不幸的是,我無法讓插件像我客戶的網站上那樣工作。
什麼問題?
更新
基於法比奧安棟樑答案我已經改變了代碼。不幸的是它仍然沒有工作。我更改了代碼,但仍然沒有效果。
感謝您的回答。不幸的是它不工作。我更改了代碼,但仍然沒有效果。在index.html上,我打電話給script.js,其中包含以下代碼:「鏈接插件」: – 2013-03-24 17:30:50
您還有一個錯誤,我更新了我的答案 – 2013-03-24 18:30:03
感謝您的幫助,我已經更改了它,但它仍然不工作。 – 2013-03-24 21:42:06