js脚本仅在存在警报时才起作用-而不是ajax调用 [英] js script works only when alert is present - not an ajax call

查看:74
本文介绍了js脚本仅在存在警报时才起作用-而不是ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OnClick事件调用以下datepicker函数.如果存在警报,则可以正常工作.否则,它不会显示所需的压光机.这是时间问题吗?

An OnClick event calls the following datepicker function. If an alert is present then, it works fine. Otherwise, it does not show the calender as required. Is this a timing issue?

function changeStartDate(Item){  
            alert ("alert goes here");

  $("#datepicker_" + Item).datepicker({                  
   dateFormat: 'M-dd-yy',
   onClose: function(dataText, inst){
      newDate = dataText;
                       processDateChange(newDate);
   },
  }); 

  flag = 1; 
  }

从何处调用

 '<div class="InfoBoxLong" id="StartDate_' + TransactionOrderItemID + '"><input id="datepicker_' + TransactionOrderItemID + '" type="text" size="9" id="StartDate_' +  TransactionOrderItemID + '" onClick="changeStartDate(\'' + TransactionOrderItemID + '\')"  value="' + ActivationStartDate + '"> </input></div>' +

推荐答案

可能日历日历DOM尚未完成渲染-添加alert()会阻塞页面,使该页面有时间完成渲染.使用等效的jquery.ready( http://docs.jquery.com/Events/ready# fn )呈现日历,然后仅在onclick事件上显示日历(而不是呈现日历).

Possible the calender DOM hasn't finished rendering - adding an alert() blocks the page which gives it time to finish rendering. Use the equivalent of jquery.ready (http://docs.jquery.com/Events/ready#fn) to render the calender and then only show it (rather than rendering it) on the onclick event.

这篇关于js脚本仅在存在警报时才起作用-而不是ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆