Solved

Detect the state of Spry Effects

Posted on 2010-09-02
3
457 Views
Last Modified: 2013-11-11
Hi Everybody

How can one detect the current state of a Spry effect (for example the slide effect)?
The problem seems to be that the state of the slide effect is lost when a page is refreshed or called newly after the slide effect has been executed. That leads to a problem when the effect is setup to allow "toggle". Example:

I slide down an initially invisible table by hitting the "hide/show" button. The table appears but contains a "next 25 items" button which refreshes the page to show the next 25 items pulled from a database. Now, if I hit the "hide/show" button again to toggle the table away (hide) again, the button, instead of sliding the table back up again, actually executes the initial effect of sliding it down (because after the page refresh it was initiated to the original state which is "up".

How can I make the spry slide effect "remember" the last state of the effect after the page is refreshed. Is there a way I can hand the state over to the next page by means of a variable, or ist there a way I can have the next page read out the last state of the slide effect?

Thanks for the help.
0
Comment
Question by:ichauch
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 125 total points
ID: 33590579
You could use a server-side script (PHP or ASP) and store the state of the widget in a session variable and echo that back.  How is the "Next 25" button doing its thing?  If it is a form submit, you could capture that with Spry and not refresh the page and instead just refresh the data...that would prevent the other widgets from resetting to their onload states.
0
 

Author Comment

by:ichauch
ID: 33592982
Hi Jason. Thank you for your input. I have indeed in the meantime resolved the problem with a little piece of PHP code which simply replaces the desired Spry commands in the generated page depending on the data displayed in the table. Admittedly not the most elegant solution since it does refresh the whole page, it but works solidly and avoids adding/modifying the JS in the page. No other widgets or effects are being used so that I don't have to take them into account. But again, it could have been done more elegantly for sure.
Thanks again.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 33593254
Elegance can be overrated.  If it works, it works.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now