jquery - How can I add javascript touch spin to html when call javascript function -


i have button add new row(s) table. in table row have column touch spin. want loop through array(items). make rows. below code make error uncaught typeerror: undefined not function @ function tp0

function showtable() {      $('#showtable').html("");      for(var in items) {          var no = parseint($('#tb tr').length) - 1;          var data = "<tr role='row' class='filter' >"          + "<td>" + no          + "</td>"          + "<td>"          + "<div class='form-group'>"          + "<input id='touch" + + "' type='text' value='1' name='touch" + + "' /> "          + "<script>"          + "function tp" + + " () {$(\"input[name=\'touch" + + "\']\").touchspin(); alert('ttt');}"          + "</scr" + "ipt>"          + "</div>"          + "</td>"          + "</tr>";          $('#showtable').append(data);          var method_name = "tp";         window[method_name + i]();     } } 

have ideas thanks

instead of adding functions each row, should pass row number variable predefined function:

function tp(index) {     $("input[name='touch" + index + "']").touchspin();     alert('ttt'); }  function showtable() {     $('#showtable').html("");     (var in items) {         var no = parseint($('#tb tr').length) - 1;          var data = "<tr role='row' class='filter' >"             + "<td>" + no             + "</td>"             + "<td>"             + "<div class='form-group'>"             + "<input id='touch"+i+"' type='text' value='1' name='touch"+i+"' /> "             + "</div>"             + "</td>"             + "</tr>";          $('#showtable').append(data);          tp(i);     } } 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -