編輯:
Here is the full HTML這是太長,我可以直接粘貼在這裏。我沒有創建這個頁面,我只是要清理它的問題。
我試圖從運行裏面的$(document)。就緒的功能,因爲我需要用DOM在我的函數運行之前完成加載,因爲我是綁定按鈕。這就是我的腳本中的內容:
jQuery(function($) {
alert('foo');
SI.regionSelector.init();
});
我也試過:
$(document).ready(function(){
alert('foo');
SI.regionSelecter.init();
});
但警報從未發生過。我已經在Chrome中使用調試器。我打jQuery(函數($),我沒有得到任何錯誤(事實上控制檯顯示什麼jQuery被定義爲,所以我知道我的頁面上有jQuery),然後調試器跳轉到jQuery函數的結尾,但它根本不會去報警
以下是完整的腳本:
var SI = SI || {};
SI.regionSelector = {
settings: {},
regions: [],
init: function() {
jQuery('a').click(function(e){ e.preventDefault(); });
// Start the DOMSelection tool when a region is clicked
jQuery('#region-selector .region').click(function(){
targetRegion = jQuery(this);
SetupDOMSelection();
});
// When saving, pull the values stored by the DOMSelection tool
// and stuff them into hidden fields so they can be picked up on
// the back end.
jQuery('#region-selector .save').click(function(){
jQuery('#site_ingestor_region_selector .btn.region').each(function(){
var values = {};
values.innerHTML = jQuery(this).data('innerHTML');
values.xpath = jQuery(this).data('xpath');
var id = jQuery(this).attr('id');
var $hiddenInput = jQuery('input[name="'+id.replace('btn', 'form-region')+'"]');
$hiddenInput.val(JSON.stringify(values));
});
});
jQuery('.btn.edit').click(function() {
jQuery('#site_ingestor_html_editor').css('display', 'block');
jQuery('body').css('overflow', 'hidden');
window.scrollTo(0, 0);
});
jQuery('.btn.cancel').click(function() {
jQuery('#site_ingestor_html_editor').css('display', 'none');
jQuery('body').css('overflow', 'scroll');
});
}
};
jQuery(function($) {
alert('foo');
SI.regionSelector.init();
});
在您的網頁上,此代碼是在哪? – theonlygusti 2015-04-03 14:26:13
請添加周圍的html區域...也許你的腳本沒有正確定義 – 2015-04-03 14:26:23
你能添加完整的代碼來重現問題嗎? – activatedgeek 2015-04-03 14:26:54