Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic filtering of marionette collection models with user search
    text
    copied!<p>I am trying to learn backbone marionette js and developing a small application using this framework.</p> <p>As part of the application, i am displaying list of users in composite collection view with mode contains name as only attribute. Now i want to add a search button. When user enters string in search box, i want to filter names dynamically on keyup. If he clears the text, i should reset.</p> <p>I tried to looking at event trigger and listening. But not able to exactly code in my case.</p> <p>Can someone direct me how to listen to the events. SearchBox is outside this template. Is it possible to listen to events from outside view and do actions like filtering.</p> <p>Below are my backbone model and collection view : </p> <pre><code>AttachmentModel = Backbone.Model.extend({ defaults: { name : "DefaultName" } }); //collection definition AttachmentCollectionModel = Backbone.Collection.extend({ model : AttachmentModel }); //View definition AttachmentView = Backbone.Marionette.ItemView.extend({ template : "#attachment-item-template", tagName : 'li' }); //Collection view definition AttachmentCollectionView = Backbone.Marionette.CompositeView.extend({ tagName : "ul", className : "list", template : "#attachment-collection-template", itemView : AttachmentView }); //Adding region MyApp.addRegions({ attachmentsDisplayContainer : "#attachmentsDisplayContainer" }); //Adding initializer MyApp.addInitializer(function(options){ var attachmentCollectionView = new AttachmentCollectionView({ collection : options.attachmentCollectionModels }); MyApp.attachmentsDisplayContainer.show(attachmentCollectionView); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload