How to activate selected () for my popup

I use selected () to implement my dropdown.

On my homepage I set the dropdown as the following code

//Code in home template
.bookmark_questions
  %select
    %option{value: "xxxx"} xxxxxx
    %option{value: "xxxx"} xxxxxx
    %option{value: "xxxx"} xxxxxx
    %option{value: "xxxx"} xxxxxx

//Code in home view
render: ->
  $(@el).html @template()
  @$('select').chosen()
  @

In my home view, I am trying to activate the selected " @$('select').chosen()", however, when I try to run the code, I get the following error

this.search_field [0] - undefined

enter image description here

What is the correct way to activate the one selected for my case?

+3
source share
2 answers

, , , , , , select DOM.

+3

render() , DOM , chosen , . :

DOM coffee/js, .

$ ->
  $('.bookmark_questions select').chosen()

Backbone.View chosen ,

render: ->
  @$el.trigger('liszt:updated')
+1

All Articles