| Page 1 of 1 | [ 7 posts ] |
|
Hi everyone,
I am trying to append a textbox in each of the YUI3 calendar day using 'set custom renderer'. But here comes the problem: I cannot select the text in textbox, whether by using mouse click or shift key. Later I use purge() to remove all event listeners from the node, and that works in Firefox and Chrome, but not in IE. Here is the code: http://jsfiddle.net/B6vy8/ So, - Does anyone knows what is the problem here? - What exact event prevent me of selecting text in the textbox? Thanks. |
Dante Netto
|
The Y.Calendar adds in each "pane" a preventDefault() handler to the selectionstart event. I think this is just to avoid selecting the content while interacting with the calendar, to improve the user experience.
The easiest way to disable it is to extend the Y.Calendar and overwrite the method _preventSelectionStart() with an empty function. Since it's protected, I don't see any problem in doing this. However, the event wil still be attached. If you just do _preventSelectionStart: null, then the event will not be attached, but your Calendar will log an "invalid callback" error if you has the log enabled. |
|
Thank you Dante, that works for me.
And another question: Why Y.one("#calendar").purge(true) does not work for pane.on("selectstart", this._preventSelectionStart), which in calendar/js/calendar.js line 85. How can I only detach this event rather than extend the Y.Calendar and overwrite the method _preventSelectionStart(). |
Dante Netto
|
In your jsfiddle, you do the purge in '#calendar td', but the selectionstart is attached to the pane, which is in a higher hierarchy in the DOM.
maybe if you substitute the purge you did with: calendar.get('contentBox').purge(true, 'selectionstart'); it might work. Sorry, but I don't have IE to test it right now. |
|
Sorry, I tried calendar.get('contentBox').purge(true, 'selectionstart'), but this is not working in Firefox and IE.
I also tried to put purge() in after render event, but still not working. Please look at this: http://jsfiddle.net/B6vy8/2/ Anyway, I really appreciate your answer. |
Dante Netto
|
In firefox, this happens because of the CSS rule:
.yui3-calendar-content:hover .yui3-calendar-day, .yui3-calendar-content:hover .yui3-calendar-prevmonth-day, .yui3-calendar-content:hover .yui3-calendar-nextmonth-day { -moz-user-select: none; } which is in calendar-core.css this will disable the selection for these matching elements. you can overwrite it by setting its value to text try setting this using all variations: -webkit-touch-callout: text; -webkit-user-select: text; -khtml-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; maybe it will work in IE, but I did not found anything in css files IE specific. Sorry not being able to help on that. |
|
CSS! I never thought about this. Thanks for your reminding.
About IE, I don't figure out the problem yet, so I just use the extended calendar in my code. Thank you. |
| Page 1 of 1 | [ 7 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