This support forum belongs to the Accordion Gallery Module.
Accordion has a bug tracker here: http://github.com/ipeychev/yui3-gallery/issues
| Page 1 of 1 | [ 8 posts ] |
|
Hi
When a user clicks the close button, I want to ask a confirmation and stop or resume the closing procedure based on the input. I've tried: accordion.on("beforeItemRemove", function (e) { var answer = confirm("Really destroy?"); if (!answer) { e.target.preventDefault(); } }); Without a luck. Any hint? Thanks! pbp |
Alberto SantiniYUI Contributor
|
Hello Jong-won Choi.
I tried your snippet in the following example: http://ipeychev.github.com/yui3-gallery ... items.html I added those lines after accordion.render(). It seems it works correctly: the event is triggered, if the answer is ok, the items are removed, otherwise the actino is deleted. Regards, IceBox |
|
icebox wrote: Hello Jong-won Choi. I tried your snippet in the following example: http://ipeychev.github.com/yui3-gallery ... items.html I added those lines after accordion.render(). It seems it works correctly: the event is triggered, if the answer is ok, the items are removed, otherwise the actino is deleted. Regards, IceBox That is actually incorrect. This code: e.target.preventDefault(); throws exception, because e.target does not have preventDefault function. That's why the execution stops. Jong-won Choi, there is no way to prevent that in the current version. I just added that feature and you will see it with the next CDN push. Iliyan |
|
Hi Alberto
Uh, I guess 'e.target.preventDefault is not a function' error might be raised. * * * All, Frankly. I do not know how to this properly. e.preventDefault() seems no effect. Should I implement such code myself? I thought preventDefault() is exactly for that (I may be wrong though, I've started playing with YUI just a few weeks ago and I saw preventDefault function from one of videos which I do not remember anymore) Any idea or pointer to look will be helpful Thanks! pbp |
|
Iliyan,
I posted another message after reading Alberto's (and missed yours) Thanks for the help Cheers pbp |
|
That change has been pushed to CDN already ('gallery-2011.02.18-23-10').
Iliyan |
|
Hi,
I am a bit confused. The forum mentions a correction but still it is unclear how one should implement this. I am trying to do exactly the same thing: Code: var answer = confirm("Delete?"); if (!answer) event.halt(); return answer; I expected that returning false would be enough to stop the removal operation and failing that I tried event.preventDefault() which didn't work either. In the end event.halt() does it for me. Is it the recommended way? Also is there a way to know what triggered the event in the first place? I am removing items by code which triggers this event and in this case I don't want to see the message of course. There are easy workarounds like storing a boolean somewhere but I was wondering if there is a nicer way to do it. Thank you anyway so far I am doing great stuff with your accordion. |
|
Hello,
pasx wrote: Hi, I am a bit confused. The forum mentions a correction but still it is unclear how one should implement this. I am trying to do exactly the same thing: Code: var answer = confirm("Delete?"); if (!answer) event.halt(); return answer; I expected that returning false would be enough to stop the removal operation and failing that I tried event.preventDefault() which didn't work either. In the end event.halt() does it for me. Is it the recommended way? The recommended way is shown in the first message of this thread: Code: accordion.on("beforeItemRemove", function (e) { accordion.on("beforeItemRemove", function (e) { var answer = confirm("Really destroy?"); if (!answer) { e.target.preventDefault(); } }); pasx wrote: Also is there a way to know what triggered the event in the first place? I am removing items by code which triggers this event and in this case I don't want to see the message of course. There are easy workarounds like storing a boolean somewhere but I was wondering if there is a nicer way to do it. Thank you anyway so far I am doing great stuff with your accordion. In general, there is, but it is not applicable in our case. We usually add a parameter to the event which is called "src". As value, we set UI_SRC. In the listener, we check for that value. However, in your case the best way probably would be just to remove the listener for this event before to close the item. Iliyan |
| Page 1 of 1 | [ 8 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group