refactored code to use newer version of backbone.js and underscore.js

This commit is contained in:
Mike Ng
2018-02-05 16:14:13 +04:00
parent df85aa8827
commit 1337a6994f
11 changed files with 37 additions and 45 deletions

View File

@@ -16,6 +16,7 @@ define([
var FieldListRowView = Backbone.View.extend({
tagName: "li",
className: "field-row",
template: _.template($("#list_row_template").html()),
initialize: function () {
// destroy view is model is deleted
this.model.on("change", this.onChange, this);
@@ -52,14 +53,13 @@ define([
}
},
render: function () {
var template = _.template($("#list_row_template").html(), {
id: this.model.get("id"),
position: this.model.get("sorter"),
name: this.model.get("name"),
tag: this.model.get("tag")
});
this.$el.empty().html(template);
this.$el.empty().html(this.template({
id: this.model.get("id") || "",
position: this.model.get("sorter"),
name: this.model.get("name"),
tag: this.model.get("tag")
}
));
// highlight view if edit view model match current view model
if (AdminFieldApp.fieldEditView