javascript - jQuery UI trigger datepicker -


i have span/date element below

<span class="editabledatetxt">06/10/2014</span> 

now on click of this, want show inline editable date popup (or jquery ui datepicker)

so when view rendered, have;

var self = this,                     $el = $(self.el); $el.find(".datepicker" ).datepicker(); 

and click of editabledatetxt, have;

$(document).on("click",".editabledatetxt", function () {     var input = $('<input />', {'type': 'text', 'class':'datepicker hasdatepicker', 'value': $(this).html()});     $(this).parent().append(input);     $(this).remove();     input.focus(); }); 

but datepicker not getting triggered (i cannot see date picker on ui)

am doing wrong ?

because when view rendered there no element class datepicker, added when click on editabledatetxt element. $el.find(".datepicker" ).datepicker() statement not have meaning.

so

$(document).on("click", ".editabledatetxt", function () {     var input = $('<input />', {         'type': 'text',             'class': 'datepicker',             'value': $(this).html()     });     $(this).after(input);     $(this).remove();     //create datepicker , show     input.datepicker({}).datepicker('show')     //input.focus(); }); 

demo: fiddle


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -