Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8943349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:44:59+00:00 2026-06-15T11:44:59+00:00

Given a view with a context like { id: 1, form_id: 5} , I

  • 0

Given a view with a context like { id: 1, form_id: 5}, I want to create an {{action}} link to the form using the form_id.

My view code looks like:

<script type="text/x-handlebars" data-template-name="group">
  {{action showForm form_id href=true}}
</script>

And the action in my router looks like:

showForm: function(router, event) {
  var form_id = event.context;
  router.transitionTo('root.form', { id: form_id });
},

I get an error that reads:

Uncaught Error: assertion failed: You must specify a target state for event 'showForm' in order to link to it in the current state 'root.index'.

I’m guessing that the problem is with the way I’m setting up the context for transitionTo, but I haven’t been able to figure out the correct solution.

Here is the full code to reproduce the problem:

<script type="text/x-handlebars" data-template-name="application">
  {{outlet}}
</script>

<script type="text/x-handlebars" data-template-name="group">
  {{action showForm form_id href=true}}
</script>

MyApp = Ember.Application.create({
  autoinit: false
});

MyApp.router = Ember.Router.create({
  root: Ember.Route.extend({
    index: Ember.Route.extend({
      route: '/',

      // Throws error: 
      //    You must specify a target state for event 'showForm' in 
      //    order to link to it in the current state 'root.index'
      //
      showForm: function(router, event) {
        var form_id = event.context;
        router.transitionTo('root.form', { id: form_id });
      },

      // Won't work because form deserialize finds id, not form_id 
      //showForm: Em.Route.transitionTo('root.form'),

      // This won't work either
      // showForm: Em.Route.transitionTo('root.form', { id: this.form_id }),        

      connectOutlets: function( router, context ){
        var group = Em.Object.create({ id:1, form_id: 5 });
        router.get( 'applicationController' ).connectOutlet( 'group', group );
      }
    }),
    form: Ember.Route.extend({
      route: '/form/:id',
      serialize: function( router, context ){
        return { id: context.id }
      },
      deserialize: function( router, context ){
        var form = Em.Object.create({ id: 5, name: 'my form' });
        return MyApp.Form.find( context.id );
      },
      connectOutlets: function( router, context ){
        // left out for fiddle example 
      }
    })
  })
});

MyApp.ApplicationController = Ember.Controller.extend({});

MyApp.GroupController = Em.ObjectController.extend({});
MyApp.GroupView = Em.View.extend({ templateName:  'group' });

MyApp.initialize(MyApp.router);​

And the cooresponding fiddle:

http://jsfiddle.net/jefflab/LJGCz/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:45:00+00:00Added an answer on June 15, 2026 at 11:45 am

    I was able to come up with an ugly solution to this problem using a computed property as the context of my action. The key snippets are:

    <script type="text/x-handlebars" data-template-name="group">
      <a {{action showForm view.formHash href=true}}>go to form</a>
    </script>
    
    MyApp.GroupView = Em.View.extend({ 
      templateName:  'group',
      formHash: function() {
        return { id: this.get('controller').get('form_id') };
      }.property('form_id')
    });
    

    And the working fiddle is here:

    http://jsfiddle.net/jefflab/pGv8u/

    However, after talking to Tom Dale, it is clear that the “right way” to solve to solve this problem is by using materialized objects instead of id values. If you are using Ember data, this is a great use case for the “sideloading” belongsTo feature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: Given a SQL string like CREATE VIEW TestView AS SELECT value1, value2 FROM
I have the given view and template code, when i try to run this
I'd like to make sure a given view in my test is fetching an
I am using sockets to create a POST request to a given server. The
I have a jQuery post submitting a form to a controller create action, which
I'd like to include form_fields.html.twig (view not bounded to a controller action) within edit.html.twig
I have a Django form with an fileupload. In the view I want to
i'm using code igniter and I made a form with the code igniter form
Given the following view : def comments(request): comments_list = Thing.objects.filter(thing_type=2) #Thing model extends MPTTModel
In Eclipse, can I get the View ID given a reference to one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.