NavigationUser login |
Improved Javascript (and a gotcha)I've just tried using some complex Javascript with Prophecy. The latest production release of Prophecy has vastly improved Javascript as compared with the last time I'd tried it. Which was sometime back, by the way, but since there's code by me floating around that uses workarounds to lesser Javascript functionality of older versions, I feel obligated to mention that some (all?) of these workarounds are no longer necessary. In a nutshell, the Array object is now fully supported. I can use both push() and filter() to work with Arrays, and that's quite handy. To illustrate, if I want to keep track of which ccxml scripts are active, I can do cccxmlList.push(evt.eventsource)And, later on I can use the filter method to take this session ID out out of the array: againstThis = evt.eventsourceExtremely handy, especially considering how hard I used to work around the lack of Array support. There is a gotcha. ECMAScript has a bug: if you use a script element as a direct child of the ccxml element, <ccxml>then x is created as "session.x" instead of the correct "session.ccxml.x". This causes subtle problems; e.g., if you use the assign element inside a transition to change the value of x the assignment is only in scope for the duration of that transition. To avoid this bug, use "var" explicitly: <ccxml>This creates x in the proper scope.
|
Basic InformationSearchRecent blog posts
New forum topicsActive forum topics |