Now Router.go does not seem to work on /this.slug/slug since they are dynamic I guess?
Router.route('/:category_slug/:thread_slug', function () {
I instead tried adding click event to my Thread collection using observeChanges,
// Look for when new threads are created and we are the author
// In that case switch to that topic and open the editor for us!
(function() {
var initializing = true;
Thread.find().observeChanges({
added: function(id, doc) {
if (!initializing) {
console.log(doc);
var newCategoryLink = $('li.thread-link[data-slug="' + doc.slug + '"]').length;
console.log("nr: "+newCategoryLink);
}
}
});
initializing = false;
})();
however this is called before the collection automatically causes the add of that li, so length there is 0.
Any ideas on how to accomplish this? Another more appropriate event I can listen too?
Try something like Router.go(this.slug + "/" + slug); instead. The issue with your current code (it seems) is that you’re actually saying divide this.slug by slug. Wrapping the "/" in quotes concatenates your variables together in one string. The end result is that Iron Router should be able to read this a little better