How to call onchange on dropdown via jquery plugin
I've a jquery plugin created called 'testInfo'. here is the snippet:
$('#loadtest-info').testInfo({
width: 400,
title: 'Test Info',
data:{
name: nameInfo,
status: statusInfo,
region: regions,
start: starttimeInfo,
end: endtimeInfo,
selectRegion:function switchRegion(){alert('')}
}
});
I have a dropdown that I need to perform a change event on: below is my underscore template
- '<div class="test-info" id = "test-info"><dt class="label">Region:</dt><dd class="value"><% if ( data.region.length == 1 ) {%><%= data.region %>'
+' </select><% }%><% if( data.region.length > 1 ) {%><select id = "selectedRegion"><% _.each(data.region,function(field){ %><option value ="<%= field.id%>" <%= (field.select) ? "selected" : "" %>><%= field.name %></option>'
+'<% }) %></select><% }%></dd><dt class="label">Start:</dt><dd class="value"><%= data.start %></dd><dt class="label">End:</dt><dd class="value"><%= data.end %></dd></dl></div></div>',
I want to call the onchange event via my plugin. I tried something like this:
- var self=this;
this.element.find('#selectedRegion').change(self.data.selectRegion)
there is no way i get this work. Anyone has ideas on how can I call the change event internally via plugin. I'm avoiding the use of external calling of the selector: i.e. `$( "#selectedRegion" ).change(switchRegion);