Reputation: 1158
I am googling from last one days but I never be found what's the problem in my code. My append js code is
$('.dynamic-form').append("<div class='row " + field_type + "-field" + field_count + "'>" +
"<button type='button' class='btn btn-primary' onClick='FieldEdit("+field_count + "," \''+field_type+ '\' + ")'>" + ' + "</button>");
Js funtion is
function FieldEdit(id,type) {
$('#' + type + '-field' + id).toggle();
}
I feel so much glad and thankful if any one solve out this issue. Thanks you!!!!
Upvotes: 0
Views: 143
Reputation: 11102
You need to add the proper quotes with escape for the second parameter:
... "<button type='button' class='btn btn-primary'
onClick='FieldEdit(" + field_count + ",\"" + field_type + "\")'></button>");
Console output:
<button type='button' class='btn btn-primary'
onClick='FieldEdit(1,"This string")'></button>
Upvotes: 3