Kind of a sub-question from my prior question. I can get data-x variables to work just fine. But I can't get them to work when I put them on the list items (which is necessary, as there are dynamic elements that vary on the list item). How do I refer to them? I know options.$trigger.attr("data-apiguid") will refer to <ul data-apiguid="whatever> However, how do you refer to data- elements on <li> </li>? Example below:
`$(function () {
$.contextMenu({
selector: '.context-menu-AddFavorite',
// Make the context menu appear above superfish hover
zIndex: function () {
return 990;
},
callback: function (key, options) {
//var mac = '78:AC:C0:AD:FF:14';
//var storeNbr = '59124';
//var ipaddress = '10.230.244.19';
var ipaddressPrefix = '/Stores/WorkstationIndividual/';
var ipaddress = options.$trigger.attr("data-ipaddress");
var storeNbrPrefix = '/';
var storeNbr = options.$trigger.attr("data-storeNbr");
var macPrefix = '?mac='
var mac = options.$trigger.attr("data-mac");
var APIFavoritesFlag = '&APIFavoritesFlag=' + key;
var apiguidPrefix = '&APIguid=';
var apiguid = options.$trigger.attr("data-apiguid");
var link = ipaddressPrefix + ipaddress + storeNbrPrefix + storeNbr + macPrefix + mac + APIFavoritesFlag + apiguidPrefix + apiguid;
window.location.href = link;
},
autoHide: true,
items: {
"add": { name: "Add to Favorites", icon: "add" }
}
});
//$('.context-menu-AddFavorite').on('click', function (e) {
// console.log('clicked', this);
//})
It turns out that if I REPLICATE the context-menu-AddFavorite line inside <li data-apiguid=@q.webapi_guid>, it works. Not sure why I have to do that, but I'm not complaning.
Kind of a sub-question from my prior question. I can get data-x variables to work just fine. But I can't get them to work when I put them on the list items (which is necessary, as there are dynamic elements that vary on the list item). How do I refer to them? I know
options.$trigger.attr("data-apiguid")
will refer to<ul data-apiguid="whatever>
However, how do you refer to data- elements on<li> </li>
? Example below:`$(function () { $.contextMenu({ selector: '.context-menu-AddFavorite', // Make the context menu appear above superfish hover zIndex: function () { return 990; }, callback: function (key, options) { //var mac = '78:AC:C0:AD:FF:14'; //var storeNbr = '59124'; //var ipaddress = '10.230.244.19'; var ipaddressPrefix = '/Stores/WorkstationIndividual/'; var ipaddress = options.$trigger.attr("data-ipaddress"); var storeNbrPrefix = '/'; var storeNbr = options.$trigger.attr("data-storeNbr"); var macPrefix = '?mac=' var mac = options.$trigger.attr("data-mac");
var APIFavoritesFlag = '&APIFavoritesFlag=' + key; var apiguidPrefix = '&APIguid='; var apiguid = options.$trigger.attr("data-apiguid"); var link = ipaddressPrefix + ipaddress + storeNbrPrefix + storeNbr + macPrefix + mac + APIFavoritesFlag + apiguidPrefix + apiguid; window.location.href = link; }, autoHide: true, items: { "add": { name: "Add to Favorites", icon: "add" } } });
});`