marionette

Different styling on the third record in Backbone + Marionette + Rails

浪子不回头ぞ 提交于 2019-12-23 03:58:14
问题 I've decided to step into the Backbone arena & after searching through BB's & Marionette's doc, I'm having a little trouble with something seemingly simple. I'm simply trying to customize what's being display on the third record. Here's how I would do it just using Rails <% @posts.each_with_index do |post, i| %> <% if i == 1 || i == 7 || i == 14 %><!-- 1st, 7th, & 14th record --> display title, description & something else <% else %><!-- other records --> display only title <% end %> <% end %

Right place to start Backbone.history?

痞子三分冷 提交于 2019-12-23 03:04:19
问题 I have seen application starting Backbone.history in either addInitializer method or in "initialize:after" event. What are the advantages and disadvantages of starting Backbone.history in either of the places? In my application, I want to render certain regions in the layout while the application is waiting for big data list to get populated. Would it be advantageous to wait on starting Backbone.history after certain regions get rendered? Also, which is the right place to authenticate user ?

MarionetteJS: Using a collection with two or more views for different layouts

。_饼干妹妹 提交于 2019-12-22 11:31:17
问题 I have a UI controller that for simplicity you can think as a Folder Tree where you can select multiple folders with checkboxes. The selection is saved in the model and "on save" there rare also a few actions triggered. For usability reasons, we want to use two different visualizations of the same controller. The two UI controllers can in some layouts be present at the same time, in others only one at the time. It would be nice to be able to reuse the same collection instance across the 2 UI

How to define controller, router and app in the right order using requireJs

大城市里の小女人 提交于 2019-12-22 11:22:29
问题 I am writing a small app ( initApp.js , initApp.routinj.js , initApp.controller.js ) which modules needs to be loaded using requires. Here's my code (*). Using console.log in each modules I see that the sequence how the modules are loaded is the following: 1) initController 2) initRouting 3) initApp Is this the right order? Now another question. In initApp.controller.js I need to access the function like initHeader and initSidebar (defined in initApp.js ). But as you can see from my code (

Backbone Marionette Event Aggregator : how to listen at the App level to ItemView Event

╄→гoц情女王★ 提交于 2019-12-22 07:12:24
问题 I'm new to Marionette and can't get my head around events... I have an ItemView which trigger an event, and I would like to receive this event at the application level, but when my app listen for this event, nothing happens... If the Event Aggregator is in Application and ItemView, why this code doesn't work ? : var MessageItemView = Backbone.Marionette.ItemView.extend({ template: "#messagesTPL", tagName: 'tr', className: 'messageItem', events : { 'click': 'displayMessage' }, displayMessage:

The best way to sort a collection in a CompositeView

放肆的年华 提交于 2019-12-21 07:12:24
问题 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

How would I refresh a Backgrid table with new data?

眉间皱痕 提交于 2019-12-21 06:35:47
问题 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

How would I refresh a Backgrid table with new data?

早过忘川 提交于 2019-12-21 06:35:03
问题 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

How to attach Backbone.Marionette view to existing element without creating extra element

故事扮演 提交于 2019-12-21 04:27:18
问题 Say I have these two Backbone.Marionette views: var FooView = Backbone.Marionette.ItemView.extend({ tagName: p, id: 'foo', template: this.templates.summary }); var BarView = Backbone.Marionette.ItemView.extend({ template: this.templates.summary }); And then I want to show them inside an app region, like so: App.contentRegion.show(new FooView/BarView()); The first view would create a new element and append it to the region. I thought the second way would be more like a standard Backbone view

Availability of UI elements in Marionette.View

佐手、 提交于 2019-12-21 03:50:47
问题 I'd just like to understand the decisions behind Backbone.Marionette's view regarding UI elements. When instantiating a Marionette.View on an existing DOM element, like this: view = new Marionette.ItemView({ el: "#element", ui : { whatever : "#whatever" } }); I am able to access view.$el , the jquery selector inside view.initialize , so far so good. However, when I try to access view.ui.whatever , I only have access to the selector, ie the string "#whatever" instead of the actual $("#whatever