javascript - Backbone event trigger not being picked up. -


the code have question spans multiple pages, i'll best post what's relevant.

i've created table using d3, , on click, i'm changing model. method i'm using change method below -

    setselected:()->          @set             selected:true          console.log("selected called")          @trigger "selected"          @ 

i know in console selected called being printed.

now, in initialize function view, i've done -

initialize:()->     @columnheadings  = @options.columnheadings     @columns2display = @options.columns2display     @outertable = @options.outertable     @model.on "selected", @select()      @model.on "unselected",@deselect() 

now, select looks -

   select:()=>         console.log "selected"         console.log(@model) 

selected never printed, leads me believe either backbone doesn't know view(there view per model, 'row' view), corresponds model, or i'm making syntax error.

thanks

when this:

@model.on "selected",   @select()  @model.on "unselected", @deselect() 

you're calling @select , @deselect methods , binding return values events. parentheses make them method calls rather method references want. drop parentheses bind method references:

@model.on "selected",   @select @model.on "unselected", @deselect 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -