Skip to content Skip to sidebar Skip to footer

Iron Router Get Current Item?

Right now I have two routes in my application. There's the main page route that has a list of Ideas (just text items) and then there's a route for showing and editing Ideas. My pro

Solution 1:

I think that your approach is good. To save the new text just do something like:

Ideas.update(this._id, {$set: {text: newText}});

You can use this._id because you already set your data context in the router with data: idea, so in your Template.ShowIdea.helpers/events "this" refers to the specific idea.

Concerning your side questions:

  1. You could also use template.find() like this :

    "input div": function (event, template) {
      var newText = template.find("div").text();
    }
    

But it is less straightforward and I think that event.target is better as the DOM element is already populated (also note the difference between event.target and event.currentTarget but there is no issue in your example).

  1. I never found any other documentation for Iron Router apart the Guide you mentioned.

Post a Comment for "Iron Router Get Current Item?"