Build search box searching in your app


#1

I would build an easy search box in my Notes.Application for searching though my notes. I looking in this form and in google and I there are not so many solutions. I found just two and don’t fit in my App :frowning: The problem is that I don’t have a general idea how to do it.

Here is my app:

<script type="text/x-handlebars" data-template-name="index">  
    <div class="wrap">
      <div class="bar">
      {{input type="text" class="search" placeholder="Where is my bookmark??" value=search action="query"}}

        <div class="bar-buttons">
          <button {{action "addNote"}}> NEW </button>
          <button> HOME </button>
        </div>
      </div>
      <aside>
        <h4 class="all-notes">All Notes {{length}}</h4>
          {{#each item in model}}
            <li>
              {{#link-to 'note' item}} {{item.title}} {{/link-to}}
            </li>
          {{/each}}
      </aside>
      {{outlet}}
    </div> 
</script>

Controller:

Notes.IndexController = Ember.ArrayController.extend ({
search: '',

actions:{
	query: function() {
      // the current value of the text field
      var query = this.get('search');
    },

	addNote: function () {
		this.transitionToRoute('main');
	}
}
});

Model:

Notes.Note = DS.Model.extend ({
title: DS.attr('string'),
body: DS.attr('string'),
url: DS.attr('string')

});

Notes.Note.FIXTURES = [ { id: 1, title: ‘hello world’, body: ‘ciao ciao ciao ciao’, url: ‘’ }, {
id: 2, title: ‘javascript frameworks’, body: ‘Backbone.js, Ember.js, Knockout.js’, url: ‘…’

},
{
    id: 3,
    title: 'Find a job in Berlin',
    body: 'Monster, beralinstartupjobs.com',
    url: '...'
}
];

But anyway this is still hardcoded data, later will be just notes added dynamically from the user.

Any suggestion is really appreciated :slight_smile: