javascript - Copying the js objects value into the html as string -
i want create html elements using values of javascript objects not global.
if run following code, take error: "params not defined". want copying value argument in html code.
if (params.data.allowedoperations.indexof('put') != -1) { return "<a onclick=\"ahey('put',params.data.allowedoperations)\" href=\"#\"> put </a>"; }
you use:
if (params.data.allowedoperations.indexof('put') != -1) { return "<a onclick=\"ahey('put','"+params.data.allowedoperations+"')\" href=\"#\"> put </a>"; }
alternatively create anchor node , add eventlistener or store operations in different attribute e.g.:
if (params.data.allowedoperations.indexof('put') != -1) { return "<a onclick=\"ahey('put', this.dataset.allowedoperations)\" data-allowed-operations=\""+params.data.allowedoperations+"\" href=\"#\"> put </a>"; }
Comments
Post a Comment