--- a/client/js/main.js Tue Aug 21 12:46:11 2012 +0200
+++ b/client/js/main.js Tue Aug 21 16:27:26 2012 +0200
@@ -84,24 +84,35 @@
if (!_opts.search.length) {
this.$.find(".Rk-Search-Form").detach();
} else {
- var _tmpl = Rkns._.template('<option value="<%= name %>"><%= name %></option>');
- this.$.find(".Rk-Search-Select").html(
- Rkns._(_opts.search).map(function(_name) {
- return _tmpl({name:_name});
+ var _tmpl = Rkns._.template('<option value="<%= key %>"><%= value.title %></option>'),
+ _select = this.$.find(".Rk-Search-Select"),
+ _input = this.$.find(".Rk-Search-Input")
+ _form = this.$.find(".Rk-Search-Form");
+ _select.html(
+ Rkns._(_opts.search).map(function(_value, _key) {
+ return _tmpl({
+ key: _key,
+ value: _value
+ });
}).join("")
- );
+ ).change(function() {
+ _form.submit();
+ });
+ _form.submit(function() {
+ if (_input.val()) {
+ var _search = _opts.search[_select.val()];
+ _this.tabs.push(
+ new _search.bin(
+ _this,
+ Rkns._({ search: _input.val() }).defaults(_search)
+ )
+ );
+ }
+ return false;
+
+ });
}
- this.$.find(".Rk-Search-Form").submit(function() {
- _this.tabs.push(
- new Rkns.Bins[_this.$.find(".Rk-Search-Select").val()](
- _this,
- {
- search: _this.$.find(".Rk-Search-Input").val()
- }
- )
- );
- return false;
- });
+
this.$.find(".Rk-Bins")
.click(function(_e) {
if (_e.target.className == "Rk-Bin-Title") {