pwalczyszyn / backstack Goto Github PK
View Code? Open in Web Editor NEWSimple Backbone extension library providing alternative mechanism to navigate/route between application views.
License: Apache License 2.0
Simple Backbone extension library providing alternative mechanism to navigate/route between application views.
License: Apache License 2.0
Hi guys,
Has anyone implemented a "Stack" effect, please share your code. Instead of "sliding", I'd like the Views to come in from the right and stack on top, and slide out to the right when popped.
Thanks,
A.
using BackStack version 1.1.2
getting error while initializing BackStack.StackNavigator
Code is in this gist.
When the "Notes" link is clicked, the notes template is loaded and is visible for about half a second, then the view changes to solid white.
At this point stackNavigator.viewsStack
consists of 3 objects:
[0].instance.el = "html div element" with innerHTML of <div id="container">Notes are here</div>
[1].instance = null
[2].instance.el = "html div element" with innerHTML of <div id="container">Notes are here</div>
No errors are raised at any point, the view just simply disappears.
I should point out that the issue occurs whether I am viewing the page in Chrome or in my PhoneGap application in the iOS Simulator.
viewChanging and viewChanged are only fired a single time when "Notes" link is clicked.
If I apply an effect like
var fade = new BackStack.FadeEffect();
stackNavigator.pushView(new NotesPage({}), {}, fade);
The affect actually occurs as the NotesPage is (incorrectly) disappearing, NOT as it is appearing.
Is there a way how to use Backpack with sidebar-body layout? I mean traditional ipad layout with independent sidebar and body part? If so, can you share some example?
Hello,
I wuld like to ask for a hint. I'm using the backstack with trigger.io for mobile app (testing currfently on android phone) and have problem that I cant resolve. I have a list of products iwant display using BackStack pushView(). Prodocts displays correctly but the view doesnt scroll verticaly (and it should because I have many products/items). When I dont use Backstack and just replace the container div with the same html as used with back stack, the scroll bar appears correcly. Is there something I miss?
Thank you ...
I think it will be useful to have some kind of caching, to re-use already rendered views. For example, I use the following function to cache my templates, maybe you can add something similar? (of course minus the template stuff). Great job on the window stack btw!
var TemplateCache = {
get: function(id,view){
if (!this.templates){ this.templates = {}; }
var template = this.templates[id];
if (!template){
template = view;
// precompile the template, for underscore.js templates
// template = _.template(template);
this.templates[id] = template;
}
return template;
}
}
I then call this.$el.append(TemplateCache.get("#list-item"));
When I called popView one too many times I got the error 'Error: Popping from an empty stack!' which is correct as I didn't have any views left; but if you try to pushView a new view after having gotten that error it will not push the new view at all, you need to re-instatiate BackStack in order to make it work and use it again.
I've added a "Tab Bar" to my project and it has introduced a bug.
Let's take for example a Tab Bar like this:
Home and Notes are a single page. Tasks has a button to "View Task" which takes you to a second View (ViewTask).
When any Tab Bar item is clicked, I want the StackNavigator.viewsStack to have only the new page in it. If you are on "Notes" and click "Home", when the page shows ONLY "Home" should be in the viewsStack.
I accomplished this with a simple piece of code:
while(stackNavigator.viewsStack.length > 2) {
var item = stackNavigator.viewsStack.pop();
}
I used "length > 2" because there seems to always be a null instance at viewsStack[0] so this would leave at least 1 item there (the current View) before calling replaceView to switch to the new View.
Functionally, it works perfect, except if I am 2 Views deep (say inside Tasks --> ViewTask) the current View (ViewTask in this case) doesn't go away, the new View just renders over the top of it and Console displays the error "webkitTransitionEnd didn't trigger in time".
If I use popAll() or replaceAll() I get an error about "cannot call method 'trigger' of null" at Backstack line 606.
Hi. This looks awesome. Whats the best way to use it if I am using Marionette on top of Backbone ?
When I do pushView, then on that new view I do popView, the old view does not have the data that was previously assigned to it.
For example in View1 during Init I populate "this.model" and use it during "this.render". It works fine when I come in with pushView (and pass in options).
When I do popView from View2, suddenly View1 doesn't have any "this.options" and "this.model" cannot be set properly.
This feels like a bug as I won't always have access to the information I need when I am doing a popView….since I am only trying to go Back.
If you are using Backstack like me and you are planning to instantiate Views with different Collections(so not the same instantion over the whole app) be careful to use this because it's gonna render your views multiple times and will also execute other events/functions multiple times. A total nightmare.. So be careful
Quick example:
var View1 = new Backbone.View.extend({
initialize: function() {
this.title = "View 1";
}
};
var View2 = new Backbone.View.extend({
initialize: function() {
this.options.title = "View 2";
}
}
navigator.pushView(View2);
navigator.pushView(View1);
At this point if you examine navigator.viewsStack you will see that "View2" has "options.title" set, but "View1" does not have "title" set.
Obviously I can use "options" if I need to but to have to set options on every value I want to be useable from my StackNavigator instance seems a bit excessive.
Hey,
I tried do use backstack with bbb (https://github.com/tbranyen/backbone-boilerplate) but i got lot's or conflicts when i try to import backstack with requirejs.
I tried' to rewrite the header of the plugin (as backbone.layoutmanager does)
(function(window) {
"use strict";
// Alias the libraries from the global object.
var Backbone = window.Backbone;
var _ = window._;
var $ = window.$;
}(this, function ($, _, Backbone) {
.....
But Now I get this error:
Uncaught TypeError: Cannot read property 'StackNavigator' of undefined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.