Passing an argument to an event in dojo 1.7+


I want to pass an argument to an event in dojo 1.7+.
Suppose I have the following module:

define(
        [ "dojo/dom", "dojo/dom-style", "dijit/registry", "js/busyIndicator",
          "dojox/mobile/ListItem", "dojo/dom-class",
          "ppwidgets/MyCommunitesRecentListItem", "js/utils" 
        ],
        function(dom, domStyle, registry, busyIndicator, ListItem, 
                 domClass, MyCommunitesRecentListItem, utils) {

            return {
                sortBy: function(sortType) {

            }};
        }
);

<h3>In html:</h3>

In regular html I can do this: onClick = "sortBy ('date')"
, but in dojo, I have to use this:
data- dojo -attach-event = "onClick: _sortBy"
I want to bind the sortBy () function to the button . How to pass the sortType function to the sortBy () function.
Thanks in advance:)

+4
source share
2 answers

Dojo partial(). .

, , . .

define(
        [ "dojo/dom", "dojo/dom-style", "dijit/registry", "js/busyIndicator",
          "dojox/mobile/ListItem", "dojo/dom-class",
          "ppwidgets/MyCommunitesRecentListItem", "js/utils" ,
          "dojo/_base/lang" // need to add this module.
        ],
        function(dom, domStyle, registry, busyIndicator, ListItem, 
                 domClass, MyCommunitesRecentListItem, utils, lang) {

            var myFunc = function( sortType ) {
            };
            var partialFunc = lang.partial (myFunc, sortType );

            return {
                sortBy: partialFunc 
            };
        }
);
0

sortType HTML event.target.sortType . ,

data-dojo-attach-event, .:)

0

All Articles