2012-10-10 08:32:49 +09:00
|
|
|
Template.category_item.events({
|
|
|
|
'click .edit-link': function(e, instance){
|
|
|
|
e.preventDefault();
|
2013-03-15 15:38:01 +09:00
|
|
|
var categoryId = instance.data._id;
|
2013-02-18 12:13:27 +09:00
|
|
|
var name = $('#name_'+categoryId).val();
|
|
|
|
var slug = slugify(name);
|
2012-10-10 08:32:49 +09:00
|
|
|
if(name){
|
2013-02-18 12:13:27 +09:00
|
|
|
Categories.update(categoryId,{ $set: {name: name, slug: slug}});
|
2012-10-10 08:32:49 +09:00
|
|
|
}else{
|
|
|
|
Categories.remove(categoryId);
|
|
|
|
}
|
2014-01-06 19:59:35 +02:00
|
|
|
Meteor.call('updateCategoryInPosts', categoryId, function(error) {
|
|
|
|
if (error) {
|
|
|
|
throwError(error.reason);
|
|
|
|
}
|
|
|
|
});
|
2012-10-10 08:32:49 +09:00
|
|
|
}
|
|
|
|
})
|