2013-03-07 92 views
1

我希望对某些工作有所了解,现在不是,我不明白为什么。从jquery对话框返回的值通过ajax加载

这是在VB和jQuery中使用asp.net。

我有一个页面,我有一个约会选择屏幕,屏幕显示分支机构的列表以及每个分支机构使用中继器的可用约会数量。

在点击具有指定约会次数的块之一后,jquery通过经过分支和日期的ajax调用另一个.aspx页面。此页面使用这些来生成一个表单来显示日期。通过ajax返回的HTML然后用于填充div的HTML元素,该元素显示为JQuery对话框。

在这个对话框是每个可用时间中的链接,当点击文本框称为time_selected充满链接“[” & Selected_Time &“]”和一个文本框称为TIME_ID充满“|” & Select_Booking_Slot_ID &“ǁ”

在我们有获得对话框(包括文本框)的HTML和使用环境的日期和ID的分隔符来获取信息,分析它的关闭事件的对话框的初始加载我们需要。

现在我强调,这个WAS在页面的一个实例上工作,我已经去创建一个移动版本的同一页面,它不再工作...也回去比较原来的我找到原始不再有效。

返回的HTML不再包含已附加的文本框的内容。

这里是加载选择页面并将其放入主页面中的关闭事件对话框的代码。

 $("a.showslots").click(function() { 
      $("#<%=bookingslot_branch.ClientID %>").val($(this).attr('branch')); 
      $("#<%=bookingslot_date.ClientID %>").val($(this).attr('date')); 
         $.ajax({ 
          url: "appointment_select_small.aspx?slots=" + $(this).attr('id') + "&date=" + $(this).attr('date') + "&branch=" + $(this).attr('branchtext') + "&branchid=" + $(this).attr('branch'), 
          context: document.body 
         }).done(function (data) { 
          $("#Slots").html(data); 
          $("#Panel_Slots").dialog({ 
           modal: true, 
           resizable: false, 
           close: function (event, ui) { 
            var data = $("#Panel_Slots").html(); 
            var test_str = data; 

            var start_pos = test_str.indexOf('[') + 1; 
            var end_pos = test_str.indexOf(']', start_pos); 
            var text_to_get = test_str.substring(start_pos, end_pos); 

           var start_pos1 = test_str.indexOf('ǀ') + 1; 
           var end_pos1 = test_str.indexOf('ǁ', start_pos1); 
           var text_to_get1 = test_str.substring(start_pos1, end_pos1); 

           if (text_to_get.length != 0) { 
            $("#<%=bookingslot_time.ClientID %>").val(text_to_get); 
            $("#<%=bookingslot_id.ClientID %>").val(text_to_get1); 
            $("#<%=btn_bookingslot_click.ClientID %>")[0].click(); 
           } 
           //$(this).remove(); 
           return false; 
          } 
         }).parent().find('.ui-dialog-titlebar-close').hide(); 
         $("#Panel_Slots").dialog('open'); 
         $("#Panel_Slots").position({ 
          of: window, 
          my: "center center", 
          at: "center center" 
         }); 
        }); 
        return false; 
       }); 

然后在这里是appointment_select_small.aspx

   $("a.bookappointment").click(function() { 
       $("#time_selected").val("[" + $(this).attr('id') + "]"); 
       $("#time_id").val("ǀ" + $(this).attr('bid') + "ǁ"); 
       $("#Panel_Slots").dialog('close'); 
       return false; 
      }); 

代码的任何帮助将不胜感激,谢谢。

+0

何时何地在appointment_select_small.aspx中的代码被调用? – iappwebdev 2013-03-07 09:59:36

+0

我刚刚注意到,在开发时,我的Visual Studio被挂钩到IE9进行调试,但是我的IE浏览器显示IE7标准为文档模式。我打算通过一些验证,希望能够解决我的问题。挂上你的午餐... – 2013-03-07 10:20:09

+0

Whua ...用IE调试!可怕的经历。只有好的事情是分析器才能观察到大量的JavaScript资源需求。 – iappwebdev 2013-03-07 10:25:43

回答

0

现在解决了这个问题,我试图向DOM中添加额外的元素,然后试图读取它,这让我很困惑。我在jQuery中找到绑定函数,所以遵循ajax加载,我将事件绑定到新创建的A标记,并且直接拉取我需要的属性。