make find work in list demo

This commit is contained in:
Rolux 2010-07-02 18:32:16 +02:00
parent ba3410eaf3
commit 17f5f7b1e3
2 changed files with 32 additions and 4 deletions

View file

@ -2024,7 +2024,10 @@ requires
function submit() { function submit() {
Ox.print("input submit", that.$input.val()) Ox.print("input submit", that.$input.val())
that.$input.trigger("blur"); 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) { that.height = function(value) {

View file

@ -441,6 +441,32 @@ $(function() {
$loadingIcon.stop(); $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) { $.each(groups, function(i, group) {
Ox.Event.bind(null, "select_group_" + group.id, function(event, data) { Ox.Event.bind(null, "select_group_" + group.id, function(event, data) {
$list.options({ $list.options({
@ -452,7 +478,6 @@ $(function() {
operator: "=" operator: "="
}; };
}); });
Ox.print
return app.request("find", $.extend(options, { return app.request("find", $.extend(options, {
query: constructQuery() query: constructQuery()
}), options.callback); }), options.callback);
@ -468,7 +493,7 @@ $(function() {
query: constructQuery(group_.id) query: constructQuery(group_.id)
}), options.callback); }), options.callback);
} }
}) });
} }
}); });
}); });
@ -515,7 +540,7 @@ $(function() {
}); });
function constructQuery(groupId) { 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) { if (v.id != groupId) {
return v.conditions; return v.conditions;
} }