marionette

Can Backbone render a collection in reverse order?

允我心安 提交于 2019-12-04 11:34:03
问题 I'm using a Signalr hub to subscribe to events on the server. What an event is dispatched to a hub, its successfully adding the item to a Marionette CollectionView. This, in turn, is rendered to a table. Because the table of events is essentially a blotter, I'd like the events in reverse order and preferably only keep n-number of events. Can Backbone 'automatically' re-render a collection in reverse order? 回答1: To go through collection in the reverse order I usually use a construction like

Backbone Marionette, Composite View initializes twice

时间秒杀一切 提交于 2019-12-04 11:18:32
问题 I'm using a composite view that has $.dialog called on it's $el. The composite view is then listing items from a collection. Now i've tried multiple ways to render the collection items: fetching from outside the composite view before and after attaching it to the view, fetching inside the view, preloading the collection from my server script, etc... all seem to work but the same problem occurs.. as soon as the composite view see's this collection, it calls it's own initialize function again..

Template two models in one view - Backbone/Marionette

£可爱£侵袭症+ 提交于 2019-12-04 10:55:49
问题 I'm trying to use two models in one view, and template using both of them. I'm working with Marionette. Here is me initialization of the view: main_app_layout.header.show(new APP.Views.HeaderView({ model: oneModel, model2 : twoModel} )); Here is my view: APP.Views.HeaderView = Backbone.Marionette.ItemView.extend({ template : '#view_template', className: 'container', initialize: function() { //This correctly logs the second model console.log(this.options.model2); } }); And here is the template

Marionette bubble event from itemview to parent layoutview?

吃可爱长大的小学妹 提交于 2019-12-04 10:38:20
问题 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" :

MarionetteJS: Application Regions vs. Layouts [duplicate]

风格不统一 提交于 2019-12-04 09:48:03
问题 This question already has an answer here : What to use since Marionette Application Regions are deprecated (1 answer) Closed 3 years ago . I was reading the documentation of the latest version (2.3.0) and it is saying that Application Regions are now deprecated. Application Regions Warning: deprecated This feature is deprecated. Instead of using the Application as the root of your view tree, you should use a Layout View. To scope your Layout View to the entire document, you could set its el

How to initialize the selection for rails-select2 in BackboneForms schema?

风流意气都作罢 提交于 2019-12-04 06:46:19
问题 The project uses marionette-rails, backbone-on-rails, select2-rails and this port to BackboneForms to provide a multiselect form field. The select options are available to the user. They are retrieved from the collection containing the total list of options: MyApp.module("Products", function(Products, App, Backbone, Marionette, $, _) { Products.CustomFormView = Products.CustomView.extend({ initialize: function(options) { this.model.set("type", "Product"); Products.EntryView.prototype

Marionette.js with Rails (Devise) Authentication

自作多情 提交于 2019-12-04 04:01:00
问题 Curious as to how people usually handle this. My strategy is to have an authorized root route and unauthorized root route. The authorized users get sent directly to my marionette.js single page application and unauthroized users get sent into a standard rails landing page with the option to login or register. It seems you could combine these all into your single page application. You could show/hide ui elements based on a class you attach to elements based on the authorization needed to see

Understanding Backbone and Marionette View lifecycle

烂漫一生 提交于 2019-12-04 03:28:43
I'm new to this world and I need to understand some of the concepts of Backbone and Marionette. Here I'm trying to explain some of the concepts I'm learning. It would be great to having some feedback on them. The render function defines the logic for rendering a template. When it is finished, the onRender callback is called. Here I suppose the rendered view has been not attached to the DOM. It is composed by a tagName (the default is div ) that contains the template I attached to it. To explicitly insert that tag into the DOM I need to append it somewhere. Am I wrong? In general, I do the

The best way to sort a collection in a CompositeView

巧了我就是萌 提交于 2019-12-03 23:47:56
I am trying to sort a collection in a Marionette.CompositeView . I have a collection which looks like this: [ {id: 1, name: 'bar'}, {id: 2, name: 'boo' }, {id: 3, name: 'foo' } ] I need to sort the collection by id in reverse order. Actually it work only when I reload the page. When I add a new model, the new item is added apparently random to the list. If I refresh the page, they will be well sorted. My questions are: 1) how to fix the problem when I add a new model? 2) it will be possible to improve the code? Here is my code: return Marionette.CompositeView.extend({ initialize: function () {

How would I refresh a Backgrid table with new data?

末鹿安然 提交于 2019-12-03 21:57:23
I have a Backgrid view on my page with a collection of data. Above the Backgrid view is another view called "filters" that allows the user to change the date range for the data so they can see results between two dates. I'm not sure what the cleanest way is to refresh the contents of the Backgrid view. Here is my code as it stands: // Fetch data var fetchingOrders = CRM.request("orders:entities"); // Create layout var ordersLayout = new List.OrdersLayout(); $.when(fetchingOrders).done(function (orders) { var ClickableRow = Backgrid.Row.extend({ events: { "click" : "rowClicked" }, rowClicked: