JQuery datepicker not working after ajax call

后端 未结 5 1607
一向
一向 2021-01-18 09:57

I have the following code


    
       //included all jquery related stuff ..not shown here
    
    
               


        
5条回答
  •  醉梦人生
    2021-01-18 10:47

    This may be a primitive solution, but I found that If I have in my main document a function MakeDatePicker and I used it in the OnChange portion of my input, I was able to make any object, ajax, or otherwise, turn into a date picker before, and after an ajax call. Here is the function and the call. (please note, I have ColdFusion # functions, as this is a return on a coldfusion query with a CFOutput.)

    
    

    here is the function at the top of my page:

    function MakeDatePicker(obj) { $(obj).datepicker({ changeMonth: true, changeYear: true }); $(obj).datepicker("show"); }

    like I said, its crude, but it works.

    I was having an issue with the way my tables would display their sorts. I have it so when you enter the page, you have 1 field that you can click on to select a date. If you click on one of the headers, it would sort SQL command, and re-display the table. This would break the .datepicker function. So I change it to not read off the class, but make the click, trigger the function. the problem with trying to get it to run on the .class was it would initialize after the table was redrawn and lose the scope of the DOM.

提交回复
热议问题