JavaUser JavaUser - 10 months ago 103
jQuery Question

mustache js syntax to call a function with parameter?

I am using Mustache.js to create a template html and show set of tables.
I want to call a function inside this template with a parameter.

Every table generated from through mustache template is having a button on top of it.
I want to write a onclick function for this button.So I need the table name when processing the event.

Can someone give me the correct syntax to pass parameter?

<script id="TableTemplate" type="x-tmpl-mustache">
<button type="button" id=Edit_{{tableName}} onclick="editTable({{tableName}})">

function editTable(tableName){
console.log("tableName >>>"+tableName)



You are doing it almost right. Just add the quotes.