To reproduce:
becomes
Then try implementing singleEventHandler as below:
The problem is e only has two properties: target and context
target is not the button which has triggered the event but the button which has opened the action sheet, so there is no way to know which button in the action sheet has been triggered in the event handler.
If not a bug, this is in my opinion a design issue which prevents properly factoring code as the only workaround is to multiply event handlers when it is not always necessary.
- Take the sample at http://demos.kendoui.com/mobile/actionsheet/index.html
- Modify to call the same event handler
<
ul
data-role
=
"actionsheet"
id
=
"inboxActions"
data-open
=
"onOpen"
data-popup
=
'{"direction": "left"}'
>
<
li
class
=
"km-actionsheet-title"
>Monday Meeting:</
li
>
<
li
><
a
href
=
"#"
data-action
=
"reply"
>Reply</
a
></
li
>
<
li
><
a
href
=
"#"
data-action
=
"replyAll"
>Reply All</
a
></
li
>
<
li
><
a
href
=
"#"
data-action
=
"archive"
>Archive</
a
></
li
>
</
ul
>
becomes
<
ul
data-role
=
"actionsheet"
id
=
"inboxActions"
data-open
=
"onOpen"
data-popup
=
'{"direction": "left"}'
>
<
li
class
=
"km-actionsheet-title"
>Monday Meeting:</
li
>
<
li
><
a
href
=
"#"
data-action
=
"singleEventHandler"
>Reply</
a
></
li
>
<
li
><
a
href
=
"#"
data-action
=
"singleEventHandler"
>Reply All</
a
></
li
>
<
li
><
a
href
=
"#"
data-action
=
"singleEventHandler"
>Archive</
a
></
li
>
</
ul
>
Then try implementing singleEventHandler as below:
function singleEventHandler(e) {
if (<
some
test involving e>) {
$("#actionResult").html("Replying to message #" + e.context);
} else if (<
some
other test involving e>) {
$("#actionResult").html("Replying to all in message #" + e.context);
} else if (<
some
other test involving e>) {
$("#actionResult").html("Archiving message #" + e.context);
}
doMoreStuff();
}
The problem is e only has two properties: target and context
target is not the button which has triggered the event but the button which has opened the action sheet, so there is no way to know which button in the action sheet has been triggered in the event handler.
If not a bug, this is in my opinion a design issue which prevents properly factoring code as the only workaround is to multiply event handlers when it is not always necessary.