You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
968 B
32 lines
968 B
var Backgrid = require('backgrid');
|
|
|
|
module.exports = Backgrid.Cell.extend({
|
|
className : 'toggle-cell',
|
|
events : {"click" : '_onClick'},
|
|
_onClick : function(){
|
|
var self = this;
|
|
this.$el.tooltip('hide');
|
|
var name = this.column.get('name');
|
|
this.model.set(name, !this.model.get(name));
|
|
this.$('i').addClass('icon-spinner icon-spin');
|
|
this.model.save().always(function(){
|
|
self.render();
|
|
});
|
|
},
|
|
render : function(){
|
|
this.$el.empty();
|
|
this.$el.html('<i />');
|
|
var name = this.column.get('name');
|
|
if(this.model.get(name)) {
|
|
this.$('i').addClass(this.column.get('trueClass'));
|
|
}
|
|
else {
|
|
this.$('i').addClass(this.column.get('falseClass'));
|
|
}
|
|
var tooltip = this.column.get('tooltip');
|
|
if(tooltip) {
|
|
this.$('i').attr('title', tooltip);
|
|
}
|
|
return this;
|
|
}
|
|
}); |