From 4aaf7d6f35af78ed2cf4e3974c88bccda5f9c9b9 Mon Sep 17 00:00:00 2001 From: Rolux Date: Fri, 2 Jul 2010 18:32:16 +0200 Subject: [PATCH] make find work in list demo --- build/js/ox.ui.js | 5 ++++- demos/test/list.js | 31 ++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 1a537be..0282626 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -2024,7 +2024,10 @@ requires function submit() { Ox.print("input submit", that.$input.val()) that.$input.trigger("blur"); - that.triggerEvent("submit", that.$input.val()); + that.triggerEvent("submit", self.option ? { + key: self.option.id, + value: that.$input.val() + } : that.$input.val()); } that.height = function(value) { diff --git a/demos/test/list.js b/demos/test/list.js index ab2bd2c..10f30a5 100644 --- a/demos/test/list.js +++ b/demos/test/list.js @@ -441,6 +441,32 @@ $(function() { $loadingIcon.stop(); }); + Ox.Event.bind(null, "submit_find", function(event, data) { + findCondition = { + key: data.key == "all" ? "" : data.key, + value: data.value, + operator: "~" + }; + $.each(groups, function(i, group) { + $group[i].options({ + request: function(options) { + delete options.keys; + return app.request("find", $.extend(options, { + group: group.id, + query: constructQuery(group.id) + }), options.callback); + } + }); + }); + $list.options({ + request: function(options) { + return app.request("find", $.extend(options, { + query: constructQuery() + }), options.callback); + } + }) + }); + $.each(groups, function(i, group) { Ox.Event.bind(null, "select_group_" + group.id, function(event, data) { $list.options({ @@ -452,7 +478,6 @@ $(function() { operator: "=" }; }); - Ox.print return app.request("find", $.extend(options, { query: constructQuery() }), options.callback); @@ -468,7 +493,7 @@ $(function() { query: constructQuery(group_.id) }), options.callback); } - }) + }); } }); }); @@ -515,7 +540,7 @@ $(function() { }); function constructQuery(groupId) { - var conditions = $.merge(!Ox.isUndefined(findCondition.query) ? [findCondition] : [], $.map(groups, function(v, i) { + var conditions = $.merge(!Ox.isUndefined(findCondition.key) ? [findCondition] : [], $.map(groups, function(v, i) { if (v.id != groupId) { return v.conditions; }