json2html eventData example

两盒软妹~` 提交于 2019-12-02 13:40:13

问题


It is my understanding from json2html Usage -> jquery that events can be hooked up inside json2html(), but there doesn't seem to be an example in Examples -> jquery.

Please show a json2html eventData example.


回答1:


not too sure if I understand your question exactly .. are you looking for examples on how to use events with jquery.json2html? or how to pass an object to keep context using eventData?

In either case here's a simple example that does both:

var data = [{'name':'click me'}];

var transform = {'tag':'button','html':'${name}','onclick':function(e){console.log(e.data);}};

$('#buttons').json2html(data,transform,{'eventData':'some data object'});


来源:https://stackoverflow.com/questions/22313664/json2html-eventdata-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!