I just needed to reobtain the latest Spry libraries only to find that they’ve released the 1.6 version earlier this morning along with a funky new website (or have i missed that before?). Check it out
A collegue of mine was making his first exploits with Spry and ran into an interesting problem. Given an XML packet like;
Using tools like Cooktop xpath searches like //bar and //bar[@parentid=1] returns exactly what you’d expect but no matter what we tried we couldn’t get this to work as part of a Spry xpath statement.
I asked Ray if he may know - we knew the xpath syntax was right but Spry wasn’t play nice. He promptly went off and a few hours later sent me a link to Spry Tester - what a guy! Later on I caught up with Sean and he offered the exact same xpath syntax so I knew we must be on the right path…to cut a long story short we’d posted to the Spry Forums and Kin from Adobe responded that the google xpath library that Spry uses doesn’t like the word ‘parent’ in it. Playing around it also seems like it doesn’t like the word ‘child’ either - so just be careful how you name your xml nodes/attributes and subsequently search your xml with xpath if you’re using Spry!
I’d been wanting to play with Spry for ages now but couldn’t find a project to use it on, but a recent project involved quite long winded forms which require conditional validation based on previous responses and such like. I had originally used jQuery with a validation widget but when I brought in Spry to do a 2 selects related drop down things didn’t play well.
Fortunately for me, the new 1.4 Spry release brought with it Form Validation (or was it there around before 1.4, i could be wrong???). Out of the box, it’s not immediately obvious how to perform conditional validation but a post onto the Spry Forums revealed a direction to look in, making use of functions destroy() and reset() in the Spry library.
So here’s my setup; a page with a set of radio buttons say for example asking for a persons sex, male or female (this is a hypothetical situation!) and if a user chooses female then they are required to fill in additional details. The javascript I ended up writing looked like this;
What’s happened here is that if a user selects Female then it displays the div and creates a new spry validation object(s), if the user then changes back to Male then it resets and destroys the validation objects…very neat!
EDIT: Turns out the validation objects weren’t being reset/destroyed with my original code, the trick is not to var the validation objects!
Recent Comments