In an intranet app I have HTML elements with custom tags.
There are several types of tags, data-mem is one example.
In the markup it looks like this:
<a href="something.html" data-mem='{varname: "value", varname2: "value"}'>Bla Bla</a>
What I want to do is get the json attribute and use the name/value pairs in a JS method call. Note: both names and values are unknown and dynamic and I’m using jquery.
RegEvent('varname','values','varname2','value');
What I have done up till now is get the list of all tags containing a data-mem attribute:
var objs = $('a[data-mem]');
I’m a little lost now. Don’t really know how to continue.
Any suggestions?
Thank you!
The extraction part of your problem has been answered well by a few people. It looks like you are also trying to get an arbitrary conversion from
{a:1, b: 2}toRegEvent('a', 1, 'b', 2).To do that, you just need to loop through the arguments of the stored JSON and build an argument array. Once complete, you can RegEvent.apply to pass those arguments to the function.