vendredi 21 août 2015

Simple search with Emberjs not working

I am trying to implement a simple search feature, which will filter the results and update the listing.

I tried almost every single tutorial out there, every tutorial seems to be working with its jsfiddle but when I apply the same thing on my project, it does not work at all.

Here is what I am having as a first problem, my search field does not seems to be bound with computed property in controller.

I also tried it as a component but again same issue, if I type anything in search field it does not reflect anything.

Let me share my code here,

input type="text" value=searchText placeholder="Search..."

  searchResults: ( ->
    console.log "On every key press it should come here.."
    model = @get('model')
    searchText = @get('searchText')
    filterByPath = @get('filterByPath')
    visualPath = @get('visualPath')

    if searchText
      searchText = searchText.toLowerCase()
      model = model.filter(item) ->
      Ember.get(item, filterByPath).toLowerCase().indexOf(searchText)>= 0
      model.getEach(visualPath)

    ).property('searchText')

Tried almost the same thing with component, but no luck so far. I am not using handlebars but Emblemjs.




Aucun commentaire:

Enregistrer un commentaire