TL DR A line starting with the @ symbol in the property name of the event object in the Backbone.Marionette view is processed by Marionette. Marionette will match the line after @ui. and replace it with the corresponding value in this representation ui hash. In your example, "click @ui.destroy" becomes "click .destroy-btn" .
Marioneton ui
Marionette has been fortified with a little syntactic sugar to help you better organize your DOM dependencies. In other words, puppet views can use the ui hash in your view, which contains references to DOM elements inside this el view. In your example, you set
ui: { "destroy": ".destroy-btn" }
This assumes that your presentation template will contain at least one element with the class .destroy-btn . After displaying your view, Marionette will call view.bindUIElements , and each member of your ui hash will be populated with a jQuery object that represents the elements (elements) that correspond to the selector passed to the ui object.
So in your view this.ui.destroy will return a jQuery object for the .destroy-btn inside your el view.
Puppet parses events hash
Another thing that Marionette will do for you, and , where your question comes in , analyzes your events hash. If he finds any events properties that include the @ui. prefix @ui. , it will write the line after . and return the selector stored in the ui hash.
So if you have
events: { "click @ui.destroy": "warnBeforeDestroy" }
Marionette will give Backbone an event hash that looks like this:
events: { "click .destroy-btn": "warnBeforeDestroy" }
Further link
See Events for Puppets and bindUIElements
source share