This is how i rewrote the functions by the way.
var benchpress = require(['benchpress']);
function handlerClickCard_btnEdit(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
var uid = $(this).attr('data-item-uid');
if (!uid) return undefined;
var item = ajaxify.data.list.find(function(itm) {
return itm && itm.uid === uid
});
var categories = ajaxify.data.categories;
// set selected option in selectbox
if (item.category && item.category.cid) {
categories.forEach(function(itm) {
if (itm && itm.cid === item.category.cid) itm.selected = true;
});
}
benchpress.parse(self.config().templates.modalEditAlbum, {
item : item,
isEdit : true,
categories : categories,
SETTINGS : ajaxify.data.SETTINGS,
}, function (html) {
bootbox.dialog({
title : '[[gallery:placeholder.edit]]' + ' "' + item.name + '"',
message : html,
});
});
}
function handlerClick_btnNewGallery() {
var categories = ajaxify.data.categories;
benchpress.parse(self.config().templates.modalEditAlbum, {
item: {
isPublic: false,
},
isNew : true,
categories : categories,
SETTINGS : ajaxify.data.SETTINGS,
}, function (html) {
bootbox.dialog({
title : '[[gallery:placeholder.edit]]' + ' "' + item.name + '"',
message : html,
});
});
}
It this what you had in mind @PitaJ ?