How to add an element with many parameter using jQuery?
I've tried the following but did not succeed:
var appendNewStoredFile = '<a href="javascript:void(0)" data-bind="event: {click: function (){ LoadQuery(viewModel,';
appendNewStoredFile += fileName;
appendNewStoredFile += ',';
appendNewStoredFile += TypesOutput
appendNewStoredFile += ',';
appendNewStoredFile += '1';
appendNewStoredFile += ');}}" class="list-group-item ItemInList" style="background-color: beige"><span style="margin: 0 5px">';
appendNewStoredFile += fileName;
appendNewStoredFile += '</span></a>';
$('#StoredQuery').append(appendNewStoredFile);
Output:
<a href="javascript:void(0)"
data-bind="event: {click: function (){ LoadQuery(viewModel,Test-Error,T_Motors,1);}}"
class="list-group-item ItemInList" style="background-color: beige">
<span style="margin: 0 5px">Test-Error</span>
</a>
Parameters are not included in quotation. I want be like:
<a href="javascript:void(0)"
data-bind="event: {click: function () { LoadQuery(viewModel,'Test-Error','T_Motors',1);}}"
class="list-group-item ItemInList"
style="background-color: beige">
<span style="margin: 0 5px">Test-Error</span>
</a>
LoadQuery(this)and then after adding the element, select it and$(element).data("file-name", fileName);and for the others parameters. Inside the function, access it bydata()function.