Skip to content

Instantly share code, notes, and snippets.

@otakustay
Created September 26, 2014 12:05
Show Gist options
  • Save otakustay/c45d0d5b910427e5b635 to your computer and use it in GitHub Desktop.
Save otakustay/c45d0d5b910427e5b635 to your computer and use it in GitHub Desktop.
Extern search
exports.search = function () {
var event = {
filterData: []
};
event = this.fire('search', event);
if (!event.preventDefault()) {
// 如果没有外部提供搜索条件,就自个儿玩
if (this.searchBox) {
var defaultFilter = {
value: this.getChild('search-box').getValue()
};
event.filterData.push(defaultFilter);
}
}
this.searchByFilters(event.filterData);
};
exports.searchByFilters = function (filters) {
// ...
};
exports.activate = function () {
this.$super(arguments);
this.target.on(
'search',
function (e) {
var filter = {
value: this.locateSearchBox().getValue();
};
e.filterData.push(filter);
e.preventDefault();
}
this
);
};
exports.activate = function () {
this.$super(arguments);
this.target.on(
'search',
function (e) {
var filters = u.chain(this.locateSelects())
.invoke('getValue')
.map(function (value) { return {value: value}; })
.value();
e.filterData.push(filter);
e.preventDefault();
}
this
);
};
<esui-search-box data-ui-id="foo"></esui-search-box>
<esui-select data-ui-id="alice"></esui-select>
<esui-select data-ui-id="bob"></esui-select>
<esui-table-rich-select data-ui-id="data"
data-ui-search-box-filter-type="SeachBoxFilterCollector"
data-ui-search-box-filter-search-box="foo"
data-ui-select-filter-type="SelectFilterCollector"
data-ui-select-filter-selects="alice bob">
</esui-table-rich-select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment