所以我在聚合物元素
中有一些选择元素和一个如此声明的按钮...
<tr>
<td>
<select name="taskTypes" selectedIndex="{{selectedTaskTypeFilter}}">
<option template repeat="{{key in taskTypeIndexes}}" value="{{key.toString()}}">
{{taskTypes[key]}}
</option>
</select>
</td>
<td>
<select name="taskStatusFilter" selectedIndex="{{selectedStatusFilter}}">
<option template repeat="{{key in statusFilterIndexes}}" value="{{key.toString()}}">
{{statusFilters[key]}}
</option>
</select>
</td>
<td>
<select name="targetLanguage" selectedIndex="{{selectedTargetFilter}}">
<option template repeat="{{language in activeTargetLanguages}}" value="{{language.code}}">
{{language.name}}
</option>
</select>
</td>
</tr>
<button value="Filter" class="btn btn-primary" on-click="{{filterStream}}">
<i class="icon-refresh icon-white"></i> {{localisation.getTranslation("index_filter_task_stream")}}
</button>
...
(Inb4有人惋惜使用表格;它本来不是我的代码,我有点想替换它们,但它不是最优先考虑的事项。)
这是按钮应该调用的filterStream()
函数,但似乎根本没有被调用,因为print语句的输出没有显示出来。
void filterStream()
{
print("Entered filterStream");
filter = "";
if (isFiltered) {
filteredTasks.clear();
filteredTasks.addAll(filteredTasksBackup);
}
if (filteredTasksBackup.length == 0) {
UserDao.getUserTasks(userid, taskCount)
.then((List<Task> userTasks) {
filteredTasks = userTasks;
filteredTasksBackup = userTasks;
isFiltered = true;
});
}
if (selectedTaskTypeFilter > 0) {
//Remove all tasks but those of the selected type
filteredTasks.removeWhere((task) => task.taskType != selectedTaskTypeFilter);
}
if (selectedStatusFilter > 0) {
//Remove all tasks but those with the selected status
//The + 2 is to adjust the values so that they match correctly; task status 3 and 4 are in progress and
//complete, respectively, but on the UI filter they are the 2nd and 3rd options (hence index 1 and 2).
filteredTasks.removeWhere((task) => task.taskStatus != selectedStatusFilter + 2);
}
goToFirstPage();
}
如果有帮助,可以找到完整的ClaimedTaskStream.dart文件here。另外,因为它可能是相关的,我应该提到我运行的代码是由dart2js编译的JS。
答案 0 :(得分:0)
该方法需要有三个参数Event,detail和target
filterStream(MouseEvent e, detail, Element target) { }