So, I am using jQuery date picker and it works well. I use AJAX to go and get some content, obviously when this new content is applied, the connection is lost, I found out about this last week and discovered the .live() method.
But how to apply this to my date picker? Since this is not an event, therefore .live() will not be able to help ... right?
This is the code I use to bind date picker to my input:
$(".datefield").datepicker({showAnim:'fadeIn',dateFormat:'dd/mm/yy',changeMonth:true,changeYear:true});
I do not want to call this method every time my AJAX fires, since I want to keep it as general as possible.
Greetings :-)
EDIT
As an @nick request below, my wrapper function got the ajax() method:
var ajax_count = 0; function getElementContents(options) { if(options.type===null) { options.type="GET"; } if(options.data===null) { options.data={}; } if(options.url===null) { options.url='/'; } if(options.cache===null) { options.cace=false; } if(options.highlight===null || options.highlight===true) { options.highlight=true; } else { options.highlight=false; } $.ajax({ type: options.type, url: options.url, data: options.data, beforeSend: function() { if(++ajax_count==1) { $.blockUI({message:'Loading data, please wait'}); } }, success: function(responseText) { if($(options.target).is("input")) { $(options.target).val(responseText); } else { $(options.target).html(responseText); } if(options.highlight===true) { $(options.target).trigger("change").effect("highlight",{},2000); } }, complete: function () { if(--ajax_count===0) { $.unblockUI(); } }, cache: options.cache, dataType: "html" }); }
How about this solution, I have rules.js that includes all of my original bindings with elements, if I have to put them in a function, and then call that function on the ajax method callback, this way I will not repeat the code .. .
Hmmm, please think: D