主要问题是 square-space 使用 java 脚本(YUI)构建其表单。他们已经将代码加载到准备好的文档中。我怎样才能等到他们的表格加载?这只是 IE 中的问题。
我的代码:(首先执行)
$(document).ready(function() {
$('#formFieldEl6').each(function(){
var collection = $.deparam.querystring(window.location);
$(this).val(collection.id);
$(this).attr("disabled", true);
});
});
Squarespace 代码:(最后执行)
var theForm10248992;
YAHOO.util.Event.onDOMReady(function() {
theForm10248992 = new Squarespace.FormBuilder( "theForm10248992", "formOuterContainer10248992", "formFields10248992", "formAddFieldControl10248992", "formErrorMessage10248992", "formSubmitButton10248992", 10248992, true , false , false , "Thanks for responding!" );
theForm10248992.initializeField( 6, "normal", "Title1", "", true, "", "", 1504386 );
theForm10248992.initializeField( 9, "normal", "Title2", "", true, "", "", 1504463 );
theForm10248992.initializeField( 4, "medium", "Title3", "", true, "", "", 1504387 );
theForm10248992.initializeField( 1, "medium", "Title4", "", true, "", "", 1504395 );
theForm10248992.initializeField( 2, "large", "Title5", "", true, "", "", 1504390 );
theForm10248992.initializeField( 1, "small", "Title6", "", true, "", "", 1599975 );
if (Squarespace.Orderable) { Squarespace.Orderable.ItemManager.initialize(); }
});
该代码只是填充 URL 中的值并禁用该控件。这适用于 FF 和 Chrome。当使用 IE 中的开发人员工具进行调试时,我可以手动等待断点,直到表单加载,然后代码才能工作,但我仍然无法让它在正常设置下工作。有什么想法吗?
最佳答案
$(document).ready()
当 html 和 css 加载时触发。它不会检查图像是否已加载。
尝试一下 $("body").load(function(){alert("body 已加载");})
这会在 html、css 和图像加载时触发,通常会晚一点。
或者,考虑使用计时器在 document.ready 触发后几毫秒运行代码。
关于javascript - 我的 jquery 运行时未加载 Squarespace 表单(在 IE 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6364097/