Events dijit/form/Select onSelect事件

Events dijit/form/Select onSelect事件,events,dojo,Events,Dojo,除了onChange之外,还有其他事件可以用dojo/form/Select注册吗 每次用户选择一个选项时,我都需要执行回调函数,即使他选择的选项与上次选择的选项相同。我尝试过的选项:onSelect、onClick不起作用 var spatialSelectionStore = new Memory({ data: [ { label: "Rectangle", id: "RECT" }, { label: "Po

除了onChange之外,还有其他事件可以用dojo/form/Select注册吗

每次用户选择一个选项时,我都需要执行回调函数,即使他选择的选项与上次选择的选项相同。我尝试过的选项:onSelect、onClick不起作用

        var spatialSelectionStore = new Memory({
        data: [
            { label: "Rectangle", id: "RECT" },
            { label: "Polygon", id: "POLY" },
            { label: "Circle", id: "CIRC" },
            { label: "Freehand", id: "FREE" }
        ]
    });

    var os = new ObjectStore({ objectStore: spatialSelectionStore });

    spatialQuerySelect = new Select({
        id: "selectionType",
        style: { width: "100px" },
        store: os,
        onChange: activateDrawTool
    }, "cp_selectByShapeId");
    spatialQuerySelect.startup();

我找到了一种方法,虽然这可能不是最好的方法,但似乎有效

我设置了一个方面,以便在执行
Select.\u setValueAttr
函数后启动函数,每次单击菜单下拉列表或下拉项目时,小部件都会启动该函数。因此,我添加了一个检查,以确保函数回调仅在单击菜单项时触发(即,在菜单关闭后)。我还必须手动删除您添加到
Select
onChange
回调,因为这会干扰方面

HTML

<div id="foo"></div>

方面可能非常强大,但是如果您使用太多并且过于依赖它们,最终可能会导致糟糕的代码混乱,因此我建议您谨慎使用它们,并且仅在必要时使用

如果您不熟悉它们的工作,您可以告诉一个方面在另一个方法前后激发
,该方面将“监听”该方法的激发,并在函数回调中表现出适当的行为

这也适用于所有选项

onExecute: function(){
            // summary:
            //      Attach point for notification about when a menu item has been executed.
            //      This is an internal mechanism used for Menus to signal to their parent to
            //      close them, because they are about to execute the onClick handler.  In
            //      general developers should not attach to or override this method.
            // tags:
            //      protected
        },

onChange
onClick
确实是最好的方法。您能告诉我们您尝试了什么以及为什么您的尝试不起作用吗?上面的代码可以工作,但仅适用于onChange事件。
spatialQuerySelect.dropDown.on("execute",function() {
alert(spatialQuerySelect.get('value'));
});
onExecute: function(){
            // summary:
            //      Attach point for notification about when a menu item has been executed.
            //      This is an internal mechanism used for Menus to signal to their parent to
            //      close them, because they are about to execute the onClick handler.  In
            //      general developers should not attach to or override this method.
            // tags:
            //      protected
        },