dagda1
dagda1

Reputation: 28860

Ember.Button not firing

I have an Ember.Button defined in the following view and I cannot get the click event handler to bind to the controller action:

<label for="url_search_url">Url</label>
<input id="url_search_url" name="url_search[url]" size="30" type="search" {{bindAttr value="urlSearch.search_url"}}>
{{#view Ember.Button target="Lead.Controllers.UrlSearch" action="search" }}
        Search
{{/view}}

And here is my controller:

Lead.Controllers.UrlSearch = Ember.Object.extend
  init: ->
    @_super()

    @url_search = Lead.UrlSearch.create()

    @url_search.set('search_url', 'http://www.bdec-online.com/bd-cmpy/bd-cz.cfm')

    @view = Ember.View.create
      controller: @
      urlSearchBinding: 'controller.url_search'
      templateName: 'app/templates/url_search/show'
      didInsertElement: ->
        $('#url_search_url').focus()
      urlSearch: @

    @view.appendTo('#fieldset')

  search: ->
    console.log('got here')

I am pulling my hair out on this one, I simply cannot see what I am doing wrong. I have tried setting the target attribute and the targetBinding attribute but nothing seems to work.

Can anybody help?

Upvotes: 1

Views: 570

Answers (1)

ebryn
ebryn

Reputation: 4407

Looks like your problem is that your target object is a class, not an instance.

You need to create an instance of your Lead.Controllers.UrlSearch controller and use it as the target on your button.

Upvotes: 2

Related Questions