I'm using jquery(mobile) to generate a select menu which hides/shows columns of an HTML table.
Looks like this:
container = $('<select name="toggleCols" id="toggleCols" multiple="multiple"><option value="default" data-placeholder="true">Edit</option></select>');
$('.tableRows').each( function(i) {
if ( $(this).is(".toggle") ) {
var toggle = $('<option value="'+i+'">sometext'+i'+</option>');
container.find("#toggleCols").append(toggle);
});
This creates the select menu, which contains one option for each table column. Selecting this option should hide/toggle the respective table column.
However, I cannot get the change event to fire:
$("#toggleCols").change( function(){
console.log( "change" )
// do stuff
})
If I use live('change'... and have 10 columns, I get 10 console.logs every time I select a single option. So this doesn't work either.
QUESTION
Is there a way to use change without live and get a single console.log?