Problem rendering template with redirectTo #201

thiagopnts opened this Issue Sep 25, 2012 · 8 comments

4 participants


Hey guys, I have the following view:, with this template:

When I try /home directly in the browser everything works fine, the content from the #with_user is rendered, but when I redirect from / to /home through redirectTo method it doesn't render the content from #with_user helper. Any thoughts?

Chaplin – JavaScript Application Architecture Using Backbone.js member

I think you are probably forgetting about async nature of getting current user from mediator. It can be that user just ain't fetched in time you are rendering the template.


It could be, but I had this problem in mind when I implemented it, this was my approach, I render this view as a collection view, it works when accessing the page directly, but fails when after a redirect:

renderSubviews: ->
    feeds = new Feeds
    feeds.url = if mediator.user? then "/feeds/#{}" else ""

    feeds.fetch({success: -> $("#loading").hide()})

    @subview 'topbar', new TopbarView
    @subview 'status', new NewStatusView

    @subview 'feeds', new FeedsView
      collection: feeds
      container: '.feeds'
Chaplin – JavaScript Application Architecture Using Backbone.js member

@thiagopnts Were you able to isolate the problem? Is mediator.user undefined after the redirect? Can you investigate how that can happen?


I could try to isolate it. For now I made a workaround on it, by just not using #with_user helper. I'm still passing mediator in getTemplateData, the problem was that when I use redirectTo, handlebars helper method #with_user wasn't called.


how does your with_user helper look like?


Hi andriijas, it was like this:

Handlebars.registerHelper 'with_user', (options) ->
  console.log 'with_user helper'

  context = mediator.user.attributes, context, options)

if the user is not logged in mediator.user will probably null.


context = mediator.user?.serialize() or {}

Chaplin – JavaScript Application Architecture Using Backbone.js member

Closing as worksforme.

@paulmillr paulmillr closed this Oct 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment