I have some code that loads some html from another file that works as it should. But I'm trying to access elements from this recently loaded data.
I have this code:
var widgetSettings = $("<div>").addClass("widgetsettings").load('dashboard/chart-settings-form.php #editChartForm'); widgetSettings.appendTo(widget.element); //so far so good... widget.element.find('.date').each(function(i){ $(this).datetimepicker(); //this doesn't work console.log('testing... '+$(this).attr('id')); //this doesn't even work... });
I expect him to find these text fields in the form of "#editChartForm" downloaded from the above URL (they are in the table):
<input type="text" name="datefrom" id="datefrom" class="date" /> To: <input type="text" name="dateto" id="dateto" class="date" />
html is definitely loading. It's just very vague why I cannot access any elements from the load () event.
I also wanted to apply the click function to the cancel button in the same form, and I found that the only way to make it work is to put it in a βliveβ function before loading:
$('.cancel').live('click', function() {
Any ideas what is going on?
source share