Failed to bind twitter bootstrap typeahead for JQuery Generated rows with text fields -
i have table single row, rows has text field in first cell , text field in bind twitter bootstrap typeahead in separate js file. users can create rows using add button , first row cloned create additional rows. expected typeahead work fine in these cloned text fields doesn't , no error displayed in console. cloned text fields have same id , name original text field. idea why might be? , suggestions on how handle it?
i'd guess .typeahead() not being initiated on dynamically created/cloned rows. can trigger event when row added , attach typeahead using jquery .on()...
$('#btnaddrow').click(function(){ var newrow = $('<div class="row"><input type="text" placeholder="start typing.." class="typeahead" data-items="3"></div>'); newrow.insertbefore('#addrow'); $('.typeahead').trigger('added'); }); $('.typeahead').on('added',function(){ $('.typeahead').typeahead(typeaheadsettings); });
Comments
Post a Comment