We have a table with data. My goal is to pass an argument from parsed JSON value to another javascript function - named newStory(value['stories']) from onclick method.
Tried a lot of different methods with no success..
json[key]['date'] = '<span class="' + styleBlock + '">' + value['date'] + '</span>';
json[key]['category'] = '<span class="' + styleCatDefault + '">' + value['category'] + '</span>';
json[key]['subcategory'] = '<span class="' + styleSubcatDefault + '">' + value['subcategory'] + '</span>';
json[key]['stories'] = '<span><a href="#" onclick="newStory(value['stories'])">' + value['stories'] + '</a></span>';
Any help appreciated!
Edit:
Line with many quotes finally worked:
json[key]['stories'] = '<span><a href="#" onclick="newStory(' + "'" +value['stories'] + "'" + ')">' + value['stories'] + '</a></span>';
valueis no longer set, you get the undefined error.<a href="#" data-value="' + value['stories'] + '" onclick="newStory(this.attributes[\'data-value\'].value)" >' + value['stories'] + '</a>'