javascript - 我的 jquery 运行时未加载 Squarespace 表单(在 IE 中)

标签 javascript jquery squarespace

主要问题是 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/

相关文章:

javascript - Mapbox 将值附加到 map 单击的表单中

javascript - 如何将事件绑定(bind)到 Squarespace AjaxLoader?

javascript - 使用链接时从 Ember.js 中的 URL 中删除附加的正斜杠

javascript - 选择没有特定 id、class、xpath 等的元素

javascript - 如何在没有 document.write 的情况下在 HTML 页面中显示 JavaScript 变量

javascript - 使用闭包迭代带有变量的 jQuery 选择器

jquery - 在 jquery 中使用 .load 发送多个变量

javascript - 如何在上传前显示文件名?

javascript - 使用 jQuery 更改 SquareSpace 上的图像

javascript - 是否可以将唯一的 CSS 类附加到多个 <li> 元素,或使用 Jquery 对它们重新排序?