在完成多个表单元素的加载后加载动态元素列表

时间:2010-03-01 22:56:55

标签: asp.net jquery

我有......

  • 动态填充的选择框
  • 几个输入框
  • 提交按钮
  • 表单字段最初使用cookie加载
  • 多个动态填充的div

我想......

  • 开始加载我的DIV内容 所有FORM元素已完全加载(=填充数据,选择框已填充)



示例代码:

<script type="text/javascript">
  $(document).ready(function() {

    // Populate <select>
    var options ='';
    for (var i = 0; i < j.length; i++) {
      options += '<option value="' + i + '">' + i +  '</option>';
    }
    $("select#myid").html(options);

  })

  ...
</script>

<form>
   <select id="myselect></select>
   <input id="mytext" type="text" value="" />    
   <input type="submit" value="Search" />    
</form>

<% foreach( MyElement element in MyListing) { %>
  <div>
    <script type="text/javascript">
       $(document).ready(function() {
         DoSomething($(select#myid).val());
       })
    </script>
  </div>
<% } %>



非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

编辑额外信息:

jQuery(function($) {   // note that this is equivalent to $(document).load()
    // if we are here, then all your page and form elements have loaded.

    // Populate <select> as per your code above

    $('div').each(function(index) {    // perhaps give them a class?
        $(this).load(<<someURL>>);
        // it's not clear from your question how you intend to get the
        // dynamic content, ie: what url to use?
    });
});