Reputation: 5391
I have the following marionette app: http://slexy.org/view/s21ARG2QdP
My problem is that when I select the node in the tree, I get "selected" and "routed" alerts.
But when I select the node again I see only "selected".
Somehow I don't get into the controller function if I go to the same url.
Is anyone has an idea what am I missing?
Thanks, Alex A.
Upvotes: 0
Views: 102
Reputation: 1857
Your code is correct. Your "problem" comes from implementation of Backbone.History.navigate(fragment, options)
.
Let's look into it:
navigate: function(fragment, options) {
if (!History.started) return false;
if (!options || options === true) options = {trigger: !!options};
// Normalize the fragment.
fragment = this.getFragment(fragment || '');
// Don't include a trailing slash on the root.
var root = this.root;
if (fragment === '' || fragment.charAt(0) === '?') {
root = root.slice(0, -1) || '/';
}
var url = root + fragment;
// Strip the hash and decode for matching.
fragment = decodeURI(fragment.replace(pathStripper, ''));
if (this.fragment === fragment) return;
this.fragment = fragment;
// Truncated
....
....
}
From here you can see that when current fragment is equal to new fragment Backbone.History.navigate()
function will exit, and because of that it will not trigger your controller's action.
I think that this approach is right way to handle routing and if you need to some kind "refresh" for the current view you can use one of the several technics:
Full page refresh.
Manually call controller's action.
Upvotes: 1