Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - Live initialization of AnyTime Picker on appended element
    primarykey
    data
    text
    <p><a href="http://www.ama3.com/anytime/" rel="nofollow noreferrer">http://www.ama3.com/anytime/</a></p> <pre><code>$(".pick_date").AnyTime_picker({ format: "%W, %M %D, %z" }); </code></pre> <p>This is code to initialize AnyTime picker on <code>.pick_date</code> element. But if I append element then AnyTime doesn't work on it. Is there a way to make it work.</p> <p>I tried this:</p> <pre><code>$('#submit-buton').live("click", function() { $.ajax({ type: "POST", url: '/AddTask', dataType: 'html', success: function(data) { $("#taskModule").append(data); $(".pick_date").AnyTime_picker({ format: "%W, %M %D, %z" }); } }); }); </code></pre> <p>But no effect...</p> <p>Any idea?</p> <p>EDIT:</p> <p>This works:</p> <pre><code>&lt;div id="mydatepicker"&gt; &lt;/div&gt; &lt;input type="button" id="MyButton" value="Append" /&gt; &lt;script type="text/javascript"&gt; $(function() { var mydatepickerHtml = 'English: &lt;input type="text" id="field1" size="50" value="Sunday, July 30th in the Year 1967 CE" /&gt;&lt;br/&gt;Español: &lt;input type="text" id="field2" value="12:34" /&gt;'; $("#mydatepicker").append(mydatepickerHtml); $('#MyButton').live("click", function() { // ... }); AnyTime.picker( "field1", { format: "%W, %M %D in the Year %z %E", firstDOW: 1 } ); $("#field2").AnyTime_picker( { format: "%H:%i", labelTitle: "Hora", labelHour: "Hora", labelMinute: "Minuto" } ); }); &lt;/script&gt; </code></pre> <p>But this doesn't...</p> <pre><code>&lt;div id="mydatepicker"&gt; &lt;/div&gt; &lt;input type="button" id="MyButton" value="Append" /&gt; &lt;script type="text/javascript"&gt; $(function() { $('#MyButton').live("click", function() { var mydatepickerHtml = 'English: &lt;input type="text" id="field1" size="50" value="Sunday, July 30th in the Year 1967 CE" /&gt;&lt;br/&gt;Español: &lt;input type="text" id="field2" value="12:34" /&gt;'; $("#mydatepicker").append(mydatepickerHtml); }); AnyTime.picker( "field1", { format: "%W, %M %D in the Year %z %E", firstDOW: 1 } ); $("#field2").AnyTime_picker( { format: "%H:%i", labelTitle: "Hora", labelHour: "Hora", labelMinute: "Minuto" } ); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload