Search Results

Search found 10 results on 1 pages for 'marionette'.

Page 1/1 | 1 

  • Backbone.Marionette - Collection within CompositeView, which itself is nested in a CollectionView

    - by nicefinly
    *UPDATE: The problem probably involves the tour-template as I've discovered that it thinks the 'name' attribute is undefined. This leads me to think that it's not an array being passed on to the ToursView, but for some reason a string. * After studying similar questions on StackOverflow: How to handle nested CompositeView using Backbone.Marionette? How do you properly display a Backbone marionette collection view based on a model javascript array property? Nested collections with Backbone.Marionette ... and Derick Bailey's excellent blog's on this subject: http://lostechies.com/derickbailey/2012/04/05/composite-views-tree-structures-tables-and-more/ ... including the JSFiddle's: http://jsfiddle.net/derickbailey/AdWjU/ I'm still having trouble with a displaying the last node of a nested CollectionView of CompositeViews. It is the final CollectionView within each CompositeView that is causing the problem. CollectionView { CompositeView{ CollectionView {} //**<-- This is the troublemaker!** } } NOTE: I have already made a point of creating a valid Backbone.Collection given that the collection passed on to the final, child CollectionView is just a simple array. Data returned from the api to ToursList: [ { "id": "1", "name": "Venice", "theTours": "[ {'name': u'test venice'}, {'name': u'test venice 2'} ]" }, { "id": "2", "name": "Rome", "theTours": "[ {'name': u'Test rome'} ]" }, { "id": "3", "name": "Dublin", "theTours": "[ {'name': u'test dublin'}, {'name': u'test dublin 2'} ]" } ] I'm trying to nest these in a dropdown where the nav header is the 'name' (i.e. Dublin), and the subsequent li 's are the individual tour names (i.e. 'test dublin', 'test dublin2', etc.) Tour Models and Collections ToursByLoc = TastypieModel.extend({}); ToursList = TastypieCollection.extend({ model: ToursByLoc, url:'/api/v1/location/', }); Tour Views ToursView = Backbone.Marionette.ItemView.extend({ template: '#tour-template', tagName: 'li', }); ToursByLocView = Backbone.Marionette.CompositeView.extend({ template: '#toursByLoc-template', itemView: ToursView, initialize: function(){ //As per Derick Bailey's comments regarding the need to pass on a //valid Backbone.Collection to the child CollectionView //REFERENCE: http://stackoverflow.com/questions/12163118/nested-collections-with-backbone-marionette var theTours = this.model.get('theTours'); this.collection = new Backbone.Collection(theTours); }, appendHtml: function(collectionView, itemView){ collectionView.$('div').append(itemView.el); } }); ToursListView = Backbone.Marionette.CollectionView.extend({ itemView: ToursByLocView, }); Templates <script id="tour-template" type="text/template"> <%= name %> </script> <script id="toursByLoc-template" type="text/template"> <li class="nav-header"><%= name %></li> <div class="indTours"></div> <li class="divider"></li> </script>

    Read the article

  • Is there a CDN for backbone.marionette?

    - by Thunder Rabbit
    Getting started with Backbone and Marionette, I was about to copy the file at https://github.com/marionettejs/backbone.marionette/blob/master/lib/backbone.marionette.js to my local server, but wondered if there was a CDN version of it. For Underscore and Backbone dev, I'm including these two files, respectively: http://documentcloud.github.com/underscore/underscore-min.js http://documentcloud.github.com/backbone/backbone-min.js Is there a similar URL for backbone.marrionette.js?

    Read the article

  • undefined returned for currentView object in Backbone.Marionette

    - by ontk
    I am testing how a layout can listen to its subviews's custom events. I created a jsFiddle here where I have a layout, 2 regions and I instantiated 2 ItemViews and showed them in the layout's regions. The fiddle is in CoffeeScript. <div id="region"></div> <script id="layout-tmpl" type="text/_"> <h3>Heading</h3> <div id="content"></div> <div id="content2"></div> </script> <script id="item-tmpl" type="text/_"> <form> <label>Firstname:</lable> <input type="text" name="firstname" value="<%= firstname %>" /> <input type="button" value="Save" id="save" /> </form> </script> And the CoffeeScript is: SimpleLayout = Backbone.Marionette.Layout.extend template: '#layout-tmpl' regions: main: '#content' other: '#content2' initialize: () -> console.log @ onShow: () -> _.each @.regionManagers, (region, name, something) => console.log region.currentView # @.bindTo region.currentView, "custom:event", @callback callback: () -> alert "HELL YEAH" SimpleItemView = Backbone.Marionette.ItemView.extend template: "#item-tmpl" events: 'click #save': 'save' save: (evt) -> evt.preventDefault() @.trigger "custom:event" region = new Backbone.Marionette.Region el: "#region" layout = new SimpleLayout() region.show layout layout.main.show new SimpleItemView model: (new Backbone.Model firstname: "Olivier") layout.other.show new SimpleItemView model: (new Backbone.Model firstname: "Travis") I want the layout to listen to the ItemViews's custom events. In the onShow, I am looping through the region managers and trying to access the currentView object but it returns undefined. If I attach the same event handlers outside of the SimpleLayout class and after I show the itemviews, then the layout handlers the custom events properly. Thanks for your help.

    Read the article

  • Marionette multi user/roles application

    - by Fabrizio Fortino
    I have to build a pretty complex application using Backbone Marionette. The user interface has to handle multiple users with different roles. For example the 'admin' user will see the complete menu whereas the 'guest' user will access a subset of the same menu. Moreover some views will be accessible to all the users but the functions inside them (add, edit, delete) need to be profiled on the different roles. I am not sure about the right approach to use in order to solve this issue. I could have different templates for the different roles but in this case plenty of code will be duplicated inside them. Is there any best practice (or maybe some example) to sort my problem out using Marionette? Thanks in advance, Fabrizio

    Read the article

  • Bootstrap Backbone Marionette Modal

    - by Greg Pagendam-Turner
    I'm trying to create a dialog in backbone and Marionette based on this article: http://lostechies.com/derickbailey/2012/04/17/managing-a-modal-dialog-with-backbone-and-marionette/ I have a fiddle here: http://jsfiddle.net/netroworx/ywKSG/ HTML: <script type="text/template" id="edit-dialog"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h3 id="actionTitle">Create a New Action</h3> </div> <div class="modal-body"> <input type="hidden" id="actionId" name="actionId" /> <table> <tbody> <tr> <td>Goal: </td> <td> <input type="text" id="goal" name="goal" > <input type="hidden" id="goalid" name="goalid" > <a tabindex="-1" title="Show All Items" class="ui-button ui-widget ui-state-default ui-button-icon-only ui-corner-right ui-combobox-toggle ui-state-hover" role="button" aria-disabled="false" > <span class="ui-button-icon-primary ui-icon ui-icon-triangle-1-s"></span><span class="ui-button-text"></span> </a> </td> </tr> <tr> <td>Action name: </td> <td> <input type="text" id="actionName" name="actionName"> </td> </tr> <tr> <td>Target date:</td> <td> <input type="text" id="actionTargetDate" name="actionTargetDate"/> </td> </tr> <tr id="actionActualDateRow"> <td>Actual date:</td> <td> <input type="text" id="actionActualDate" name="actionActualDate"/> </td> </tr> </tbody> </table> </div> <div class="modal-footer"> <a href="#" class="btn" data-dismiss="modal">Close</a> <a href='#' class="btn btn-primary" id="actionActionLabel">Create Action</a> </div> </script> <div id="modal"></div> <a href="#" id="showModal">Show Modal</a> Javascript: var ActionEditView = Backbone.Marionette.ItemView.extend({ template: "#edit-dialog" }); function showModal() { var view = new ActionEditView(); view.render(); var $modalEl = $("#modal"); $modalEl.html(view.el); $modalEl.modal(); } $('#showModal').click(showModal); When I click on the show modal link the html pane goes dark as expected and the dialog content is displayed but on the background layer. Why is this happening?

    Read the article

  • backbone marionette - displaying a view in a layout region which has already been rendered

    - by Justin Wyllie
    I have something like this: //render the layout Layout.layout = new Layout.Screen(); MyApp.SomeRegion.show(Layout.layout); //render a view into it var mView = new CompositeView({collection: data}); Layout.layout.SomeRegion.show(mView); That all works fine. The layout has 3 regions. The above has rendered a view into one of them. Now, later, I want (in response to some user interaction) to render another view into one of the other regions. So I try: var mView2 = new CompositeView({collection: data}); Layout.layout.SomeOtherRegion.show(mView); But 'SomeOtherRegion' no longer exists on Layout.layout. I looked at this in Firebug. In the first case Layout.layout has my three regions defined on it. In the second case, not. Though they are still there in the regions object. This is the same layout instance. It looks like once a layout has been rendered you cannot render into it again? There must be a way. Nb. I don't want to re-render the layout. I hope that makes sense --Justin Wyllie

    Read the article

  • Marionette js itemview not defined: then on browser refresh it is defined and all works well - race condition?

    - by Robert
    Yeah it's just the initial browser load or two after a cache clear. Subsequent refreshes clear the problem up. I'm thinking the item views just aren't fully constructed in time to be used in the collection views on the first load. But then they are on a refresh? Don't know. There must be something about the code sequence or loading or the load time itself. Not sure. I'm loading via require.js. Have two collections - users and messages. Each renders in its own list view. Each works, just not the first time or two the browser loads. The first time you load after clearing browser cache the console reports, for instance: "Uncaught ReferenceError: MessageItemView is not defined" A simple browser refresh clears it up. Same goes for the user collection. It's collection view says it doesn't know anything about its item view. But a simple browser refresh and all is well. My views (item and collection) are in separate files. Is that the problem? For instance, here is my message collection view in its own file: messagelistview.js var MessageListView = Marionette.CollectionView.extend({ itemView: MessageItemView, el: $("#messages") }); And the message item view is in a separate file: messageview.js var MessageItemView = Marionette.ItemView.extend({ tagName: "div", template: Handlebars.compile( '<div>{{fromUserName}}:</div>' + '<div>{{message}}</div>' + ) }); Then in my main module file, which references each of those files, the collection view is constructed and displayed: main.js //Define a model MessageModel = Backbone.Model.extend(); //Make an instance of MessageItemView - code in separate file, messagelistview.js MessageView = new MessageItemView(); //Define a message collection var MessageCollection = Backbone.Collection.extend({ model: MessageModel }); //Make an instance of MessageCollection var collMessages = new MessageCollection(); //Make an instance of a MessageListView - code in separate file, messagelistview.js var messageListView = new MessageListView({ collection: collMessages }); App.messageListRegion.show(messageListView); Do I just have things sequenced wrong? I'm thinking it's some kind of race condition only because over 3G to an iPad the item views are always undefined. They never seem to get constructed in time. PC on a hard wired connection does see success after a browser refresh or two.

    Read the article

  • dirtyFields with itemview

    - by user1449437
    I have a master/detail application that I'm building with backbone marionette. as the user clicks the master rows, the detail will show the row details. users need to be able to edit the row. I'd like the notify them if they try to 'leave' the row before saving. I was thinking that I'd use the dirtyFields plugin for this functionality. Has anyone else used these together? when I swap out my itemview, how do I initialize the plugin? when I close the view, is there anything I should think about to clean up the view? any thoughts would be appreciated. thx

    Read the article

  • Multiple collections tied to one base collection with filters and eventing

    - by damienc88
    I have a complex model served from my back end, which has a bunch of regular attributes, some nested models, and a couple of collections. My page has two tables, one for invalid items, and one for valid items. The items in question are from one of the nested collections. Let's call it baseModel.documentCollection, implementing DocumentsCollection. I don't want any filtration code in my Marionette.CompositeViews, so what I've done is the following (note, duplicated for the 'valid' case): var invalidDocsCollection = new DocumentsCollection( baseModel.documentCollection.filter(function(item) { return !item.isValidItem(); }) ); var invalidTableView = new BookIn.PendingBookInRequestItemsCollectionView({ collection: app.collections.invalidDocsCollection }); layout.invalidDocsRegion.show(invalidTableView); This is fine for actually populating two tables independently, from one base collection. But I'm not getting the whole event pipeline down to the base collection, obviously. This means when a document's validity is changed, there's no neat way of it shifting to the other collection, therefore the other view. What I'm after is a nice way of having a base collection that I can have filter collections sit on top of. Any suggestions?

    Read the article

  • Port listening on localhost:8000 but not on ip:8000

    - by Marionette
    Hello I'm running a web application on port 8000. When I access it from the host server localhost:8000 it responds ok, 127.0.0.1:8000 also works, but 192.168.1.7:8000 does not work. 192.168.1.7 is the ip of my server. Also if i try to go to another web application running on port 80 it works 192.168.1.7 I enabled ufw firewall and set ufw default allow. I am using ubuntu server 12.04 Any suggestions on why I can't get to my app on port 8000 using the ip-address:8000? Thanks in advance!

    Read the article

1