I have an array as follows:
var dataPushArray = [
{
"name" : "name1", //Name for reference
"event": "event1", //Event to be passed
"catagory": "catagory1", //Catagory to be passed
"action": "action1", //Action to be passed
"label": "label1", //Label(s) to be passed
"trigger": "views-ac-dependent-filter", //Class or ID of click
element
},
{
"name" : "name2", //Name for reference
"event": "event2", //Event to be passed
"catagory": "catagory2", //Catagory to be passed
"action": "action2", //Action to be passed
"label": "label2", //Label(s) to be passed
"trigger": "edit-submit-hiscox-marklerportal-search", //Class or ID of click element
}
];
And I have a click event that looks at all the "triggers" in the array and if one is clicked do something:
//Define vars
var clickTriggers = [];
var pushData = "";
//Loop through all results
for(i=0;i<dataPushArray.length;i++){
//Merge click selector with click trigger
var trigger = String(dataPushArray[i].trigger);
//Puts all individual click triggers in clickTriggers array
clickTriggers.push(trigger);
}
//Click function for all click triggers
$(clickTriggers.join(',')).on('click', function(trigger) {
if(jQuery.inArray(trigger, dataPushArray)) {
//Output data here
}
})
Which works fine but what I am trying to do is get all values from the array after the specific element is clicked for instance if an element with the trigger "views-ac-dependent-filter" is clicked I then want to get the name, event, catagory, and label from that part of the array.
Any help on this would be hugely appreciated