| Page 1 of 1 | [ 4 posts ] |
|
I'm trying to use the nodeChange event to keep the toolbar i made for the text editor updated.
The "commands" key in the event object really helps me do this but it's undefined whenever i try to access it even though when you log the event object you can see it. Example - http://jsfiddle.net/aamirkapasi/eVbKg/8/ I read through the editor-base API docs and it seems that the "commands" key is only attached to the event object whenever a command is executed using execComand and that is the only time i'm supposed to see it. It being undefined makes sense now but how i can see it when i just log the event doesn't make any sense. So basically TL;DR is there anyway i can get the "commands" key or anything similar to that from the nodeChange event or do i simply have to check the changedNode and figure out what styles have been applied to it to keep my toolbar updated (which seems very messy and does not work in some edge cases). TL;DR TL;DR What is the best way to keep my text editor toolbar updated? |
|
You want the 'after' nodeChange event, not the on:
http://jsfiddle.net/davglass/tuSBH/ What you are seeing is a side effect of the browser logging an object but preserving it's reference and not cloning it (one of my pet peeves against browser debuggers). When you logged the object, the key wasn't actually there it was added later. But the browser logged a reference to that object, so it appears that it was there, when in fact it was updated after that point in time. You can see this if you do a `Y.log(Y.merge(event));`, this will clone the object at that time and allow you to print it. Make sense? |
|
Hey dav, thanks for replying.
The after nodeChange completely solved my problem and the disappearing key makes sense now but i think i've come across a bug. The commands loses both the underline and strikethrough keys if both styles are applied on the same text. http://jsfiddle.net/aamirkapasi/2nZY2/ Is this a bug or does this happen for a particular reason? |
|
Looks like a bug, you should file it and I'll look into it when I can
|
| Page 1 of 1 | [ 4 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