GlossaryContainerLayoutView.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. define([ "require", "backbone", "hbs!tmpl/glossary/GlossaryContainerLayoutView_tmpl" ], function(require, Backbone, GlossaryContainerLayoutViewTmpl) {
  2. "use strict";
  3. var GlossaryContainerLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "GlossaryContainerLayoutView",
  5. template: GlossaryContainerLayoutViewTmpl,
  6. regions: {
  7. RGlossaryLayoutView: "#r_glossaryLayoutView",
  8. RGlossaryDetailLayoutView: "#r_glossaryDetailLayoutView"
  9. },
  10. ui: {},
  11. events: function() {},
  12. bindEvents: function() {
  13. var that = this;
  14. this.options.categoryEvent && this.options.categoryEvent.on("Success:Category", function(options) {
  15. console.log("categoryEvent:"), that.renderGlossaryDetailLayoutView(that.options);
  16. });
  17. },
  18. initialize: function(options) {
  19. _.extend(this.options, options), this.bindEvents();
  20. },
  21. onRender: function() {
  22. this.renderGlossaryDetailLayoutView(this.options);
  23. },
  24. manualRender: function(options) {
  25. _.extend(this.options, options), this.renderGlossaryDetailLayoutView(this.options);
  26. },
  27. onBeforeDestroy: function() {
  28. this.options.categoryEvent.off("Success:Category");
  29. },
  30. loadGlossaryLayoutView: function(isSuccessCategory) {
  31. "category" != this.options.value.gType && this.renderGlossaryDetailLayoutView(this.options);
  32. },
  33. renderGlossaryDetailLayoutView: function(options) {
  34. var that = this;
  35. require([ "views/glossary/GlossaryDetailLayoutView" ], function(GlossaryDetailLayoutView) {
  36. that.isDestroyed || that.RGlossaryDetailLayoutView.show(new GlossaryDetailLayoutView(options));
  37. });
  38. }
  39. });
  40. return GlossaryContainerLayoutView;
  41. });