简体   繁体   中英

json2html eventData example

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.

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'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM