marionette

Rendering a closed Marionette view

隐身守侯 提交于 2019-12-05 10:38:15
Shouldn't a closed Marionette view re-delegate the defined events (events, modelEvents, CollectionEvents) when rendering again? It seems as if I have to manually call delegateEvents after closing and re-rendering a view. Otherwise the view won't work as expected. http://jsfiddle.net/4DCeY/ var app = new Marionette.Application(); app.addRegions({ main: '.main' }); var MyView = Marionette.ItemView.extend({ template: _.template('Hi, I\'m a view! Foo is: <%= foo %>'), modelEvents: { 'change': 'onChange' }, onChange: function() { alert('change!'); } }); var Model = Backbone.Model.extend({}); app

Detect click on itemview container in Backbone/Marionette

扶醉桌前 提交于 2019-12-05 08:47:43
I have the following item view: return Marionette.ItemView.extend({ template:tpl, tagName: 'div', className: 'v_itv_record_type_item', events:{ 'click @ui.item':'itemClicked' }, ui:{ item:'.v_itv_record_type_item' }, itemClicked:function(e){ console.log('clicked'); } }); that uses the following handlebars template: <div class="clicktarget"> Stuff Goes Here </div> If you click on one of these item views, it does not register the click event. I understand that Backbone restricts access to just the views slice of the DOM, but apparently this does not extend to the containing div itself, even

How to remove an Item from Selectize

强颜欢笑 提交于 2019-12-05 08:11:47
Is there any Way i can remove an item from selectize AMNT QTY NA when i pass NA it should remove particular item $.fn.removeSelectorValue = function (value) { var selectize = this[0].selectize; selectize.removeItem(value) return this; }; this is not working.. Can anyone help me out from this??? removeItem removes selected item identified by given value. To remove option from the list you should use removeOption Example - open http://brianreavis.github.io/selectize.js/ , open console and enter: $('#select-beast')[0].selectize.removeOption(1) to remove Chuck Tesla from available options I'm late

Is there a rule of thumb to decide when to use trigger or triggerMethod in Backbone.Marionette?

泪湿孤枕 提交于 2019-12-05 03:42:09
I'm playing a bit with Backbone.js and Backbone.Marionette and I would like to know what's the difference between trigger and triggerMethod . In particular, is there any rule of thumb to decide when use the former or the latter? In my mind events, for example, are useful to communicate between a DOM element and its view. triggerMethod is used in Marionette to update in cascade different components, e.g. a layout calls the show method to its children (children respond to onShow ). So, for me its the same as calling a direct method on it. Is this true? What about trigger ? Thanks you in advance.

Auto init and show view within a region on a Marionette Layout

不想你离开。 提交于 2019-12-05 02:48:20
问题 I have a Layout, with a region. When the Layout is initialized, I want it to automatically initialize a pre-set view to do into it's region, and show/close it when the Layout itself is showed/closed. Current example from https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.layout.md: AppLayout = Backbone.Marionette.Layout.extend({ template: "#layout-template", regions: { mainRegion: "#menu", content: "#content" } }); var layout = new AppLayout(); ParentAppLayout

Using precompiled handlebars templates with Marionette

牧云@^-^@ 提交于 2019-12-05 02:30:58
问题 I'm using Marionette with requirejs and I would also like to use precompiled handlebars templates. How does this work? Here my current setup: require_main.js: requirejs.config({ baseUrl: "/", paths: { 'text': 'vendor/javascripts/text', 'backbone': "vendor/javascripts/backbone", 'backbone.wreqr': "vendor/javascripts/backbone.wreqr", 'backbone.babysitter': "vendor/javascripts/backbone.babysitter", 'jquery': "vendor/javascripts/jquery", 'jquery-ui': 'vendor/javascripts/jquery-ui', 'json2':

How to show CompositeView with multiple children view in Backbone Marionette

£可爱£侵袭症+ 提交于 2019-12-05 00:29:15
问题 The Starting Problem I have a CompositeView (a table) for which each model in the collection is represented as two table rows, with a template like: <tr class="row-parent"> <td>parent info here</td> </tr> <tr class="row-child"> <td>child info here</td> </tr> With an ItemView like this: var ItemView = Backbone.Marionette.ItemView.extend({ template: ItemTmpl }); Even though they are named 'parent' and 'child', they are actually peer members of the same model. If I don't specify a tagName,

Backbone Marionette: Marionette.Application causing Require.js module load error, “'Error: Module name 'App' has not been loaded yet for context: _”

落爺英雄遲暮 提交于 2019-12-04 21:09:49
I'm trying to include the App instance to use it's event aggregator as shown here I get an error when I include the instance in a view. Kicking things off in the Requirejs config file, from App.Bootloader.js: require(['App'], function (App){ App.start(); }); from App.js: define(function (require){ //...requisite includes $, _, Backbone, Marionette ... var Layout = require('Layout'); var App = new Marionette.Application(); App.addRegions({ main: '#view_content' }); App.addInitializer(function (){ App.main.show(new Layout()); //... adding router etc ... Backbone.Marionette.TemplateCache

Marionette + i18n in templates

↘锁芯ラ 提交于 2019-12-04 20:16:06
I want to do some basic i18n in my application I loaded the i18n plugin (from require.js) to my Application and created a directory nls in which i have several files e.g. project.js I set up the default location in main.js file like config : { i18n : { locale : 'de-de' } } I now want to use the files in my View / Template. Can somebody explain to me how this is done? The templates are setup in one template.js file My View: define(['marionette', 'templates', 'i18n!nls/project'], function (marionette, templates, msg) { return marionette.CompositeView.extend({ template : templates.project }); });

Dynamically add regions to Marionette layout

自作多情 提交于 2019-12-04 19:15:58
问题 I have a layout, but cannot define all of its regions in advance because they are not known. So later on an ItemView is created and I'd like to create a new region in the layout using the view's ID as the region's name so I can then say: layout.dynamicRegionName.show(newItemView); But there is cyclic dependency here. I haven't rendered the view yet, so I cannot make a reference to its DOM element to be used in the layout's call to .addRegion() I cannot render it, precisely because I want it