regions in layout view missing attach method? #343

Closed
jeacott opened this Issue Nov 9, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@jeacott

jeacott commented Nov 9, 2012

regions in layout view seem to be missing the attach method

@derickbailey

This comment has been minimized.

Show comment
Hide comment
@derickbailey

derickbailey Nov 12, 2012

Member

can you provide some sample code for this?

Regions are built the same way for Layouts as they are for App objects... but there are some differences in when they are built and initialized. That may be what's causing this, but I will need to see some sample code that reproduces the problem.

Member

derickbailey commented Nov 12, 2012

can you provide some sample code for this?

Regions are built the same way for Layouts as they are for App objects... but there are some differences in when they are built and initialized. That may be what's causing this, but I will need to see some sample code that reproduces the problem.

@jeacott

This comment has been minimized.

Show comment
Hide comment
@jeacott

jeacott Nov 12, 2012

ok - hopefully what follows isn't too horrible.
when I try to use attach in a Marionette.Layout I get:

TypeError: this.someRegion.attach is not a function
in this case either this.inputViewRegion or this.subViewRegion

fyi 'show' works, and the same code worked as a non Marionette.Layout (just using app region).
both attach's below work when replaced with 'show'.

App.SidebarView = Backbone.Marionette.Layout.extend({
    template: "#sidebar-template",
     regions: {
            inputViewRegion: "#finder",
            subViewRegion: "#menuitemsview"
        },
      initialize: function(options){
          that=this;
      },
      test:function(context){
            console.log("firing... "+JSON.stringify(context));
      },
      onRender: function () {
          //create and load input box

          var subSelect = new Bootstrap.Typeahead({
                 el: this.$("#find"), //for clarity
                 trigger: "user:select",
                     url:"/someurl"
                });
         this.inputViewRegion.attach(subscribeSelect); //fails here
         subSelect.bind('user:select', this.onUserSelect);

         var subView=new App.MenuItemsView({collection:that.collection});

         this.subViewRegion.attach(subView); //fails here

        },
         onUserSelect: function(item){
            console.log(item);
        },

where

Bootstrap.Typeahead = Backbone.Marionette.ItemView.extend({
 tagName: 'input',
    initialize: function(options){
         var that = this;
         that.$el.affix();
...

hope it helps.

jeacott commented Nov 12, 2012

ok - hopefully what follows isn't too horrible.
when I try to use attach in a Marionette.Layout I get:

TypeError: this.someRegion.attach is not a function
in this case either this.inputViewRegion or this.subViewRegion

fyi 'show' works, and the same code worked as a non Marionette.Layout (just using app region).
both attach's below work when replaced with 'show'.

App.SidebarView = Backbone.Marionette.Layout.extend({
    template: "#sidebar-template",
     regions: {
            inputViewRegion: "#finder",
            subViewRegion: "#menuitemsview"
        },
      initialize: function(options){
          that=this;
      },
      test:function(context){
            console.log("firing... "+JSON.stringify(context));
      },
      onRender: function () {
          //create and load input box

          var subSelect = new Bootstrap.Typeahead({
                 el: this.$("#find"), //for clarity
                 trigger: "user:select",
                     url:"/someurl"
                });
         this.inputViewRegion.attach(subscribeSelect); //fails here
         subSelect.bind('user:select', this.onUserSelect);

         var subView=new App.MenuItemsView({collection:that.collection});

         this.subViewRegion.attach(subView); //fails here

        },
         onUserSelect: function(item){
            console.log(item);
        },

where

Bootstrap.Typeahead = Backbone.Marionette.ItemView.extend({
 tagName: 'input',
    initialize: function(options){
         var that = this;
         that.$el.affix();
...

hope it helps.

@ghost ghost assigned derickbailey Nov 15, 2012

@derickbailey

This comment has been minimized.

Show comment
Hide comment
@derickbailey

derickbailey Nov 15, 2012

Member

so, i dug in to this just now...

the method name is attachView, not attach. I'm honestly not sure how attach ever works... that method doesn't exist on any region objects that I know of.

also - what are you trying to do with attachView in this case? this method is specifically here to support pre-rendered HTML from a server or other rendering process ... if you have HTML that is already rendered and are attaching a region and a view to that pre-rendered content. from your sample code, it looks like you're trying to use it to display the contents of a newly created view. or am i not understanding your code?

Member

derickbailey commented Nov 15, 2012

so, i dug in to this just now...

the method name is attachView, not attach. I'm honestly not sure how attach ever works... that method doesn't exist on any region objects that I know of.

also - what are you trying to do with attachView in this case? this method is specifically here to support pre-rendered HTML from a server or other rendering process ... if you have HTML that is already rendered and are attaching a region and a view to that pre-rendered content. from your sample code, it looks like you're trying to use it to display the contents of a newly created view. or am i not understanding your code?

@jeacott

This comment has been minimized.

Show comment
Hide comment
@jeacott

jeacott Nov 15, 2012

Doh, You are correct,
I had it working with attachView previously, not attach, sorry.
I am attaching it to an existing input field in a quest to try to simply enhance server rendered markup.

jeacott commented Nov 15, 2012

Doh, You are correct,
I had it working with attachView previously, not attach, sorry.
I am attaching it to an existing input field in a quest to try to simply enhance server rendered markup.

@jeacott jeacott closed this Nov 15, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment