get_my/client/AdminMgmt/CategoryMgMt/catMgmtTbl.js
2022-08-23 13:41:21 -05:00

37 lines
No EOL
1 KiB
JavaScript

import { Categories } from '../../../imports/api/category.js';
Template.catMgmtTbl.onCreated(function() {
this.subscribe("myCategories");
});
Template.catMgmtTbl.onRendered(function() {
Meteor.setTimeout(function() {
$('.tooltipped').tooltip();
}, 150);
});
Template.catMgmtTbl.helpers({
cats: function() {
return Categories.find({});
}
});
Template.catMgmtTbl.events({
'click .deleteCategory' (event) {
event.preventDefault();
Meteor.call('delete.category', this._id, function(err, result) {
if (err) {
console.log(" ERROR deleting category: " + err);
} else {
console.log(" SUCCESS deleting the category.");
}
});
},
'click .editCategory' (event) {
event.preventDefault();
Session.set("categoryEditId", this._id);
Session.set("catEditMode", true);
let catInfo = Categories.findOne({ _id: this._id });
$("#catNameInp").val(catInfo.categoryName);
}
});