Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yeah, the call to <code>@render</code> in <code>change_list_view</code> is wiping out the element that the events are bound to in the <code>initialize</code> method.</p> <p>If you must re-render the view (like if you are changing the template) then you will just have to add a call to <code>@delegateEvents</code> below the <code>@render</code> call in <code>change_list_view</code>.</p> <p><strong>UPDATE</strong></p> <p>If you wanted to switch to a subview method, you could probably get rid of that second call to render. Something like this:</p> <pre><code># snipped all the outer require js stuff class InnerViewBase extends Chaplin.View # Or whatever your base view is autoRender: true container: "#innerViewContainer" containerMethod: "html" initialize: (templateName) -&gt; @template = require templateName super class ListViewA extends InnerViewBase initialize: -&gt; super "views/templates/list_view_a" # Do any event handlers in here, instead of the outer view # @delegate 'click', @click_ev class ListViewB extends InnerViewBase initialize: -&gt; super "views/templates/list_view_b" class ListViewC extends InnerViewBase initialize: -&gt; super "views/templates/list_view_b" class OfferListView extends View autoRender: true container: "[data-role='content']" containerMethod: 'html' initialize: -&gt; super @template = template #views # Consider changing these three id subscriptions to a class @delegate 'change', '#list_view_a', @change_list_view @delegate 'change', '#list_view_b', @change_list_view @delegate 'change', '#list_view_c', @change_list_view @delegate 'click', @click_ev afterRender: -&gt; # Add a default ListView here if you want # @subview "ListView", new ListViewA change_list_view: (event) =&gt; console.log('change') # Make a hacky looking map to the subview constructors viewNames = "list_view_a": ListViewA "list_view_b": ListViewB "list_view_c": ListViewC @subview "ListView", new viewNames[event.target.id] click_ev: =&gt; console.log('click') getTemplateData: =&gt; @collection.toJSON() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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