Skip to content

Commit 6721fc1

Browse files
committed
bugfix
Check if methods getShared and setShared exist
1 parent f5ece45 commit 6721fc1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backbone.viewstack",
3-
"version": "0.0.1",
3+
"version": "0.0.3",
44
"homepage": "https://github.com/vash15/backbone.viewstack",
55
"authors": [
66
"Michele Belluco <michele@belluco.info>"

lib/viewstack.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ var ViewStack = module.exports = BackBone.View.extend({
121121
// refresh
122122
// Aggiorna l'url se la view corrette ce l'ha settata
123123
refreshUrl: function refreshUrl(){
124-
var shared = this.getShared();
125-
if ( typeof shared !== "undefined" && this._current && this._current.url ){
124+
var shared = this.getShared ? this.getShared() : null;
125+
if ( typeof shared !== "undefined" && shared && this._current && this._current.url ){
126126
shared.app.navigate(_.result(this._current, 'url'));
127127
}
128128
return this;
@@ -172,7 +172,8 @@ ViewStack.middleware = function middleware(options){
172172
return function(shared, next){
173173
var viewStack = new ViewStack(options);
174174
viewStack.clearStack(); // Pulisco dalle eventuali view appese
175-
viewStack.setShared( shared ); // setto lo shared object
175+
if ( viewStack.setShared )
176+
viewStack.setShared( shared ); // setto lo shared object
176177
viewStack.render(); // Renderizzo la view base application
177178
shared.viewstack = viewStack;
178179
next();

0 commit comments

Comments
 (0)