diff options
| author | hukl <contact@smyck.org> | 2009-06-10 23:21:39 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-06-10 23:21:39 +0200 |
| commit | 9c5108ffab6828562c5a976ddb92ac0ec459a9a3 (patch) | |
| tree | 267099b94b50395ed629460d26f4e5641619de08 /public/javascripts/admin_search.js | |
| parent | 45e067f1108748067b727a53e7826cebbb429792 (diff) | |
added basic ajax search interface. lots of css / js improvements needed but it seems to work quite okay for now. more on that tomorrow
Diffstat (limited to 'public/javascripts/admin_search.js')
| -rw-r--r-- | public/javascripts/admin_search.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js new file mode 100644 index 0000000..d645cca --- /dev/null +++ b/public/javascripts/admin_search.js | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | admin_search = { | ||
| 2 | |||
| 3 | initialize : function() { | ||
| 4 | $("#search_term").bind("keyup", function() { | ||
| 5 | if ($(this).attr("value")) { | ||
| 6 | $.ajax({ | ||
| 7 | type: "GET", | ||
| 8 | url: "/admin/search", | ||
| 9 | data: "search_term=" + $(this).attr("value"), | ||
| 10 | dataType: "json", | ||
| 11 | success : function(results) { | ||
| 12 | admin_search.show_results(results); | ||
| 13 | } | ||
| 14 | }); | ||
| 15 | } | ||
| 16 | else { | ||
| 17 | $('#results').empty(); | ||
| 18 | } | ||
| 19 | }); | ||
| 20 | }, | ||
| 21 | |||
| 22 | show_results : function(results) { | ||
| 23 | $('#results').empty(); | ||
| 24 | for (result in results) { | ||
| 25 | $('#results').append("<p>" + results[result].title + "</p>"); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } \ No newline at end of file | ||
