没有与占位符(正常DIV)的网页。通过ajax调用,我将一个<form>
和一个<script>
加载到占位符中。脚本包含必要的JavaScript来初始化表单(即例如禁用控件以使表单只读等)。这是我的一段代码;它的工作原理,但评论部分不起作用。因为脚本引擎找不到对象tristate_DisableControl,它是我通过ajax调用的其中一个脚本中的函数。jQuery的准备功能:脚本没有检测功能
$(document).ready(function() {
// $('#site_preferences_content div').each(function() {
// if (typeof (window.tristate_DisableControl) == 'undefined') {
// if (typeof (window.console) != 'undefnied')
// console.log((new Date()).toTimeString() + ' not logable');
// pausecomp(1000);
// }
// else
// tristate_DisableControl(this);
// }); //end $('#site_prefrences_content div').each()
setTimeout(function() {
$('#site_preferences_content div').each(function() { tristate_DisableControl(this); })
}, 1000);
});
我想通过时间的$(document)。就绪()执行DOM将被正确加载中...
你在哪里加载你的脚本?请提供代码和/或标记。 – jAndy 2010-06-02 11:12:29
我向所有人道歉。问题在于放置脚本。我通过ajax调用的页面中包含2个脚本;其中一人拥有tristate_DisableControl的定义。另一个脚本使用这个函数。问题是因为先放置第二个脚本,然后是第一个脚本... – deostroll 2010-06-03 06:31:23