marionette

Backbone.History.extend( { loadUrl: …} ) returning false for valid routes

落花浮王杯 提交于 2019-12-11 03:31:22
问题 I'm trying to extend Backbone.History.loadUrl() to catch 404 errors: var History = Backbone.History.extend({ loadUrl: function() { var match = Backbone.History.prototype.loadUrl.apply(this, arguments); if (!match) { console.log('route not found'); } return match; } }); (Backbone.history = new History).start(); This is based on the solution suggested here: https://github.com/jashkenas/backbone/issues/308#issuecomment-9482299. The problem I'm encountering is that when I call (Backbone.history =

How to design a controller in Backbone.js?

你说的曾经没有我的故事 提交于 2019-12-11 02:22:29
问题 I am interested in having a controller to coordinate rendering, event processing, URL router navigation and network access. A bit similar to what a Controller does in Spine: http://spinejs.com/docs/controllers In the realm of Backbone, what I could find so far is an article by Derick Bailey: http://lostechies.com/derickbailey/2011/08/28/dont-execute-a-backbone-js-route-handler-from-your-code/ In Derick's code however, the Controller seems not to be used anymore within the Routes. Also, I was

Rendering Layouts and sub-views in Marionette / Backbone.js

為{幸葍}努か 提交于 2019-12-11 02:15:30
问题 I have a working solution in regard to rendering layouts with views in regions in a Marionette application I'm working on, but something doesn't feel right about it. Do you have to append anything directly to the DOM? Here is my method in the controller: //Grab the main Layout var layout = new APP.Views.LayoutView(); //Render that layout layout.render(); //Make the model var simpleModel = new APP.Models.simpleModel({ "field1" : "foo", "field2" : "bar" }); layout.header.show(new APP.Views

Overriding fetch in Marionette.js model (and responding to push updates)

前提是你 提交于 2019-12-11 01:45:25
问题 This is a two part question. We have a Marionette.js application wherein, on initial load, we need to "subscribe" to a Lightstreamer instance and keep that instance/connection open (not important what Lightstreamer is except that it sends updates down to the page). Subsequent model updates will generally be triggered not by user actions by by updates coming from Lightstreamer. I'm at something of a loss as to how to architect this. Firstly, it seems like the default model fetch() action makes

weird behavior of MarionetteJS compositeView

家住魔仙堡 提交于 2019-12-11 01:25:47
问题 I am working with MarionetteJS compositeView. For some reason i am getting a recursive template behavior. Usually the itemView's template is rendered within the itemViewContainer but for some reason instead of taking the itemView's template it takes it's own compositeView template. it's not english but the behavior can be visually seen here: http://www.codeforum.me/admin.html Another thing is, I have it working perfectly on my localhost but the moment i upload it and try to run it from my

How to dynamically update a Marionette CollectionView when the underlying model changes

心不动则不痛 提交于 2019-12-11 00:54:27
问题 Seems like this should be obvious, but there seem to be so many different examples out there, most of which cause errors for me, making me think they are out of date. The basic situation is that I have a MessageModel linked to a MessageView which extends ItemView, MessageCollection linked to a MessageCollectionView (itemView: MessageView). I have a slightly unusual scenario in that the MessageCollection is populated asynchronously, so when the page first renders, it is empty and a "Loading"

Populate Backbone Marionette Views with data from Mongoose using Express Route

大憨熊 提交于 2019-12-10 21:16:36
问题 Im trying to fetch the data/api using a node/express route with data stored in mongo/mongoose and show it inside Backbone Marionette... The route im using is this: enter code here`app.get('/cats', function(req, res){ Cat.find({}, function (err, docs) { res.send(docs); }); }); 2) When I go to localhost:3000/cats, I get the json working as: [ { "__v": 0, "_id": "51318ce9a7ff43f808000003", "catname": "Jonas" }, { "catname": "Justin", "_id": "51416268a8225e7413000001", "__v": 0 }, { "catname":

Adding a model to a Marionette CollectionView's collection doesn't trigger onItemAdd callback

人盡茶涼 提交于 2019-12-10 19:54:43
问题 So, I'm not sure I quite understand how this callback is supposed to be triggered. If you take a barebones model,collection and views: PatchModel = Backbone.Model.extend({}); PatchCollection = Backbone.Collection.extend({model: PatchModel}); PatchView = Backbone.Marionette.ItemView.extend({template:'#patchview'}); PatchCollectionView = Backbone.Marionette.CollectionView.extend({ itemView:PatchView ,onItemAdded: function(itemView){ console.log("item was added"); } }); And instantiate them like

Apache and Nodejs cross domain ajax issue

…衆ロ難τιáo~ 提交于 2019-12-10 18:38:56
问题 I am working on application in which I have used two servers hosted on same machine, one is apache which will work as basic host for serving php pages and other side nodejs for communication of rest api, whole application build upon backbone/marionette/requirejs/bootstrap. Coming to the point, my normal pages are load from apache server like, http://192.168.20.62/project/design.php and I have configured my model like this, define(['backbone'],function(Backbone){ 'use strict'; return Backbone

How to deploy static website connecting to Django RESTful API?

自作多情 提交于 2019-12-10 18:23:28
问题 First of all, google or SO search didn't help me: lots of tips regarding django's staticfiles, which I believe are not relevant here. I have inherited a project consisting of: Django backend in form of API returning JSON responses only; standard Swampdragon deployment pushing realtime updates to frontend; very little configuration has been done here; Frontend webapp built on Backbone and marionette.js, compiled and minified by Grunt. My problem is: the frontend needs to know addresses for