diff options
Diffstat (limited to 'public/javascripts/admin_search.js')
| -rw-r--r-- | public/javascripts/admin_search.js | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 1e6f545..186e4bc 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js | |||
| @@ -50,7 +50,7 @@ admin_search = { | |||
| 50 | menu_items = { | 50 | menu_items = { |
| 51 | 51 | ||
| 52 | initialize_search : function() { | 52 | initialize_search : function() { |
| 53 | $("#search_term").bind("keyup", function() { | 53 | $("#menu_search_term").bind("keyup", function() { |
| 54 | if ($(this).attr("value")) { | 54 | if ($(this).attr("value")) { |
| 55 | $.ajax({ | 55 | $.ajax({ |
| 56 | type: "GET", | 56 | type: "GET", |
| @@ -72,40 +72,26 @@ menu_items = { | |||
| 72 | show_results : function(results) { | 72 | show_results : function(results) { |
| 73 | $("#search_results").empty(); | 73 | $("#search_results").empty(); |
| 74 | for (result in results) { | 74 | for (result in results) { |
| 75 | var foo = $(("<a href='#'>"+ results[result].title + "</a>")); | 75 | var link = $(("<a href='#'>"+ results[result].title + "</a>")); |
| 76 | $(foo).bind("click", function(){ | 76 | $(link).bind("click", function(){ |
| 77 | menu_items.open_title_popup(); | 77 | menu_items.add_item_to_form(results[result]); |
| 78 | //menu_items.add_item_to_menu(results[result]); | ||
| 79 | return false; | 78 | return false; |
| 80 | }); | 79 | }); |
| 81 | 80 | ||
| 82 | $("#search_results").append(foo); | 81 | |
| 82 | // Sometimes I don't get jquery; wrap() didn't work *sigh* | ||
| 83 | // Guess I'll need a book someday or another framework | ||
| 84 | var wrapper = $("<div></div>"); | ||
| 85 | $(wrapper).append(link) | ||
| 86 | |||
| 87 | $("#search_results").append(bar); | ||
| 83 | 88 | ||
| 84 | } | 89 | } |
| 85 | }, | 90 | }, |
| 86 | 91 | ||
| 87 | open_title_popup : function() { | 92 | add_item_to_form : function(node) { |
| 88 | popup = $("<div><form action='#'><input id='item_title' type='text' /><input id='foobar' type='submit' /></form></div>"); | 93 | $("#new_menu_item #menu_item_node_id").val(node.node_id); |
| 89 | $("form", popup).submit(function(){ | 94 | $("#new_menu_item #menu_item_path").val("/" + node.unique_name); |
| 90 | alert("hi"); | 95 | $("#new_menu_item #menu_item_title").val(node.title); |
| 91 | return false; | 96 | } |
| 92 | }); | ||
| 93 | $("body").append(popup); | ||
| 94 | }, | ||
| 95 | |||
| 96 | add_item_to_menu : function(node) { | ||
| 97 | $.ajax({ | ||
| 98 | type: "post", | ||
| 99 | url: "/menu_items/create", | ||
| 100 | data: { | ||
| 101 | "menu_item[node_id]" : node.node_id, | ||
| 102 | "menu_item[path]" : "/" + node.unique_name, | ||
| 103 | "menu_item[title]" : node.title | ||
| 104 | }, | ||
| 105 | success : function() { | ||
| 106 | alert("s"); | ||
| 107 | } | ||
| 108 | }); | ||
| 109 | } | ||
| 110 | |||
| 111 | }; \ No newline at end of file | 97 | }; \ No newline at end of file |
