Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _contracts = new _widgetCollections.Contracts();
- _contractDropDown = new _widgetViews.contractDropDown({
- collection: _contracts
- });
- And in a seperate file this is the collection definition:
- (function (m, $, undefined) {
- (function (c) {
- (function (criteria) {
- (function (widgets) {
- (function (models) {
- models.Contract = Backbone.Model.extend({
- Value: "",
- Text: ""
- });
- }(widgets.models = widgets.models || {}));
- (function (collections) {
- collections.Contracts = Backbone.Collection.extend({
- model: widgets.models.Contract,
- parse: function (xhrResponse) {
- var r = _.map(xhrResponse, function (contract) {
- return {
- Text: contract.Text,
- Value: contract.Value
- };
- })
- return r;
- }
- });
- }(widgets.collections = widgets.collections || {}));
- (function (views) {
- views.contractDropDown = Backbone.View.extend({
- tagName: "select",
- template: "<option value='{{id}}'>{{name}}</option>",
- initialize: function () {
- _.bindAll(this, 'render');
- this.collection.bind('refresh', this.render);
- },
- render: function () {
- var
- self = this,
- contractCombobox = $('#ContractList').data('tComboBox');
- if (contractCombobox !== undefined) {
- var telerikDs = _.map(self.collection.models, function (c) {
- return c.toJSON();
- });
- contractCombobox.dataBind(telerikDs);
- }
- return this;
- }
- });
- }(widgets.views = widgets.views || {}));
- }(criteria.widgets = criteria.widgets || {}));
- }(c.criteria = c.criteria || {}));
- }(m.c= m.c|| {}));
- }(window.m= window.m|| {}, jQuery));
Add Comment
Please, Sign In to add comment