Guest User

Untitled

a guest
Jul 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. _contracts = new _widgetCollections.Contracts();
  2. _contractDropDown = new _widgetViews.contractDropDown({
  3. collection: _contracts
  4. });
  5.  
  6.  
  7.  
  8.  
  9. And in a seperate file this is the collection definition:
  10.  
  11.  
  12.  
  13. (function (m, $, undefined) {
  14. (function (c) {
  15. (function (criteria) {
  16. (function (widgets) {
  17. (function (models) {
  18. models.Contract = Backbone.Model.extend({
  19. Value: "",
  20. Text: ""
  21. });
  22. }(widgets.models = widgets.models || {}));
  23.  
  24. (function (collections) {
  25. collections.Contracts = Backbone.Collection.extend({
  26. model: widgets.models.Contract,
  27. parse: function (xhrResponse) {
  28. var r = _.map(xhrResponse, function (contract) {
  29. return {
  30. Text: contract.Text,
  31. Value: contract.Value
  32. };
  33. })
  34.  
  35. return r;
  36. }
  37. });
  38. }(widgets.collections = widgets.collections || {}));
  39.  
  40. (function (views) {
  41. views.contractDropDown = Backbone.View.extend({
  42. tagName: "select",
  43. template: "<option value='{{id}}'>{{name}}</option>",
  44. initialize: function () {
  45. _.bindAll(this, 'render');
  46. this.collection.bind('refresh', this.render);
  47. },
  48. render: function () {
  49. var
  50. self = this,
  51. contractCombobox = $('#ContractList').data('tComboBox');
  52.  
  53. if (contractCombobox !== undefined) {
  54. var telerikDs = _.map(self.collection.models, function (c) {
  55. return c.toJSON();
  56. });
  57. contractCombobox.dataBind(telerikDs);
  58. }
  59.  
  60. return this;
  61. }
  62. });
  63. }(widgets.views = widgets.views || {}));
  64.  
  65.  
  66. }(criteria.widgets = criteria.widgets || {}));
  67. }(c.criteria = c.criteria || {}));
  68. }(m.c= m.c|| {}));
  69. }(window.m= window.m|| {}, jQuery));
Add Comment
Please, Sign In to add comment