backbone-views

Marionette bubble event from itemview to parent layoutview?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 07:33:25
I have a layout view with a region, in that region I have a item view that triggers an event but it doesn't seem to be bubbled up to the layout view. Am I doing something wrong or is this designed behavior? I assume the itemview prefix is not added as the parent view is not a collection view? Either way the event is never bubbled to the layout view. layoutView = Marionette.Layout.extend({ template: "#layout-template", regions: { titleRegion: "#job-title-region" }, triggers: { "save:clicked" : "onSaveClicked" }, onSaveClicked: function (args) { alert('Clicked'); } }); childview = Marionette

Need help understanding the basics of nested views in backbone

此生再无相见时 提交于 2019-12-03 07:14:00
I've been doing a bunch of reading about nested views in backbone.js and I understand a good amount of it, but one thing that is still puzzling me is this... If my application has a shell view that contains sub-views like page navigation, a footer, etc. that don't change in the course of using the application, do I need to render the shell for every route or do I do some kind of checking in the view to see if it already exists? It would seem so to me if someone didn't hit the "home" route before moving forward in the app. I haven't found anything helpful about this in my googling, so any

How to create a base view in backbone.js?

纵饮孤独 提交于 2019-12-03 06:16:48
问题 I need to create a base view which all my views would extends. I'm not really sure where and when to declare this view. Basically, I need to inject global variables to all my templates and I don't do to that in each and every render() methods. this is my tree structure for now: |-main.js |-app.js |-require.js |-App | |-View | | |-Dashboard.js | | |-Header.js | | |-Content.js | |-Model | |-Collection | |-Template | |-Libs |-... this is my app.js var App = { ApiURL: "http://domain.local", View:

Binding multiple event types in backbone views

那年仲夏 提交于 2019-12-03 04:25:22
I was wondering if it is possible to bind multiple event types in backbone within a single line. Consider the following: var MyView = Backbone.View.extend({ id: 'foo', events: { 'click .bar': 'doSomething', 'touchstart .bar': 'doSomething' }, doSomething: function(e) { console.log(e.type); } }); Basically what I am wondering is if it is possible to combine the event binding for 'click' and 'touchstart' into one line - along the lines of: events: { 'click,touchstart .bar': 'doSomething' } Any suggestions would be appreciated. rinat.io It's impossible for views jQuery events, which are bound

How to create a base view in backbone.js?

佐手、 提交于 2019-12-02 19:41:18
I need to create a base view which all my views would extends. I'm not really sure where and when to declare this view. Basically, I need to inject global variables to all my templates and I don't do to that in each and every render() methods. this is my tree structure for now: |-main.js |-app.js |-require.js |-App | |-View | | |-Dashboard.js | | |-Header.js | | |-Content.js | |-Model | |-Collection | |-Template | |-Libs |-... this is my app.js var App = { ApiURL: "http://domain.local", View: {}, Model: {}, Collection: {}, Registry: {}, Router: null }; define(['backbone', 'View/Dashboard'],

Backbone.js - change not triggering while the name change

梦想与她 提交于 2019-12-02 14:13:42
In my backbone function, while the name get change the change function not at all triggering.. any one suggest me the right way to get it.. (actually i need to get changed stuff and need to update); code : (function($){ var list = {}; list.model = Backbone.Model.extend({ defaults:{ name:'need the name' }, initialize:function(){ this.bind('change:name', function(model) { console.log('Model->change()', model); }); } }); list.collect = Backbone.Collection.extend({ model:list.model, url : 'data/names.json', initialize:function(){ this.fetch({update:true}); this.keepUpdate(); }, keepUpdate:function

How to check if sidebar view has already been rendered in backbone?

∥☆過路亽.° 提交于 2019-12-02 12:09:35
Generally, the user enters the website through the home page and then I render the sidebar view there. Next, the user clicks a link and the router renders another view and replaces the original content view. The sidebar view is not re-rendered. When the user clicks refresh while on a sub-page, the sidebar is not rendered. How do I check whether a view exists and has been rendered? Split the responsibilities and stick to it. Don't put the sidebar rendering into the hands of the home page view. You could have a layout view which handles rendering the content , header , footer and sidebar . Then,

how to load html file in Marionette .js + backbone?

假如想象 提交于 2019-12-02 03:19:28
I have one "test.html" in that I have this contend (whole html file have this contend). <h1>First page</h1> I need to load that contend in my div having id ="contend" using Marionette .js <div id="contend"> </div> could you please tell me how I will do that ? fiddle : http://jsfiddle.net/JQu5Q/16/ $(document).ready(function(){ var ContactManager = new Marionette.Application(); ContactManager.addRegions({ mainRegion:"#contend" }) ContactManager.on("start", function(){ console.log("ContactManager has started!"); }); ContactManager.start(); // router var routers = Backbone.Router.extend({ routes:

how to switch views with the backbone.js router?

五迷三道 提交于 2019-12-02 00:39:23
问题 This is more of a conceptual question, in terms of using the backbone router and rendering views in backbone. for the sake of an example (what I'm building to learn this with) I've got a basic CRUD app for contacts, with create form, a listing of all contacts, a contact single view and an edit form. for simplicities sake I'm going to say that I would only want to see one of these things at a time. Obviously showing and hiding them with jQuery would be trivial, but thats not what I'm after. I

how to switch views with the backbone.js router?

房东的猫 提交于 2019-12-01 22:49:46
This is more of a conceptual question, in terms of using the backbone router and rendering views in backbone. for the sake of an example (what I'm building to learn this with) I've got a basic CRUD app for contacts, with create form, a listing of all contacts, a contact single view and an edit form. for simplicities sake I'm going to say that I would only want to see one of these things at a time. Obviously showing and hiding them with jQuery would be trivial, but thats not what I'm after. I have two ideas, 1) trigger custom events from my router that removes all views and sends events that