Closed mullen3 closed 10 years ago
Can someone help me with this? Is this where I would read the property and escape the col.values?
render: function () {
var self = this, isChecked, isDisabled, html,
cols = _.filter(this.view.colModel, function (col) {return !col.hidden; });
isChecked = ($.inArray(this.model.id, this.view.selectedRows) >= 0);
isDisabled = this.model.get('cb_disabled') || false;
html = this.template({
isMultiselect: this.view.multiselect,
isContainSubgrid: this.view.subgrid && this.view.subgridControl,
isSelected: this.selected || false,
isChecked: isChecked,
isDisabled: isDisabled,
values: _.map(cols, function (col) {
if (col.actions) {
col.name = 'bbGrid-actions-cell';
if (_.isFunction(col.actions)) {
col.value = col.actions.call(self, self.model.id, self.model.attributes, self.view);
} else {
col.value = self.view.actions[col.actions].call(self, self.model.id, self.model.attributes, self.view);
}
} else {
col.value = self.getPropByStr(self.model.attributes, col.name);
}
return col;
})
});
It would be this
$('
').text(self.getPropByStr(self.model.attributes, col.name)).html();But i do suggest you escape them as json data before passing into the collection, because thats the right way to do it.
escaping from inside is tricky and should not be resorted to.
Could you clarify what you mean by tricky?
Here is my pull request implementing the feature. https://github.com/direct-fuel-injection/bbGrid/pull/57
Well, what i mean by tricky is that, it can throw some other error, or unknown character if the json collection is already encoded, or not well-formed.
for the pull request, i suggest just put this line into the Render function, instead of the direct value...test it out first..
$("< div />").text(self.getPropByStr(self.model.attributes, col.name)).html();
Added in latest commit. Thank you for feedback.
As a developer, I would like an option to auto-escape fields that are passed to bbgrid.