Sorry if the question wording is bad, I'm not really sure how to describe it.
I have a button which, when clicked, does this:
function Save(id, projectID) {
var url = "@Url.Content("~/Config/Detail?id=")" + id + "&projectID=" + projectID;
var _options = {
area: ['590px', '385px'],
content: url
}
tools.openTopPage(_options);
};
If I manually enter values for id and project ID in the second line, it works, so I know there's no problem in this function.
However, when the function is called from an input string it doesn't work.
The string is here (being put into a htmlArray):
htmlArray.push(
"<td class='text-center'>
<input type='button' class='form-btn' value='修改'
onclick=Save(" + item.id + ", " + item.projectID + ") />
<input type='button' id='btn-delete' class='form-btn'
value='删除' onclick=Delete(" + item.id + ") />
</td>");
I thought the problem was due to the way the input string breaks and has variables item.id and item.projectID put into the Save() function, however it doesn't even work if I keep it simple. For example, the following doesn't work either:
htmlArray.push(
"<td class='text-center'>
<input type='button' class='form-btn' value='修改'
onclick=Save(6, 3) />
<input type='button' id='btn-delete' class='form-btn'
value='删除' onclick=Delete(" + item.id + ") />
</td>");
The values 6 and 3 which I have used are the values I would expect to be given if using item.id and item.projectID.
Most interesting is that the HTML renders the same in the browser in both cases. The result looks like this:
So surely the issue is somewhere around the Save() function, but I don't know where.
If I simplify the Save() function to take only one parameter it works (e.g. "Save(" + item.id + ")" will work fine), so this is what leads me to believe it's messing up when dealing with two parameters.
Any input much appreciated, thanks.
