While I was reading some old posts on this list about back button
support for ajax based lift applications, I came across this thread
http://groups.google.com/group/liftweb/browse_thread/thread/fc0f9983ba050614
There, Alex Boisvert suggested a way to implemented which sounds
pretty interesting, but I guess he never had the time to implement it.
I have a particular question, I know that Lift has a mechanism for
calling server side scala code from the browser, could anyone point me
to where I should look to see how it is all done?
I would like to try an implement what Alex proposed, or at least get
something close to. I know that there are some requirements to get
code into Lift, but I'll enjoy the scala exercise :) (and maybe it
could be a module).
Thanks
I'm copying Alex's proposal here:
============
Just thinking out loud as to how this could work...
On modern browsers, it's possible to monitor the state change of the
browser's URL hash (aka window.location.hash / '#' / document fragment) in
the browser with the 'onhashchange' DOM event. It gets fired whenever the
location.hash changes. On older browsers, it's also possible to poll for
change which is less efficient but that's life.
So the idea would be to:
1) add a snippet or utility method to set up a listener on onhashchange that
would callback Scala functions associated with given hash (e.g. #foo, #bar,
...). Hashes could support parameters too (e.g., #foo/:param1/:param2)
2) add a method S.ajaxHash(hashPath, callback): JsCmd that would bind a hash
path/pattern to a Scala function (by registering the path/pattern with the
listener)
3) add a method S.changeHash(hashPath, params): JsCmd to programmatically
change the browser's hash as a result of some AJAX processing.
I don't have time to work on this yet but I'd be happy to hear what others
think of the idea.
alex
============
--
Diego Medina
Web Developer
http://www.fmpwizard.com
Diego
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/liftweb/-/5SxhUqHOApkJ.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
Now I have to sleep but I'll clean up the code of the sample
application I am playing with and I'll post back.
Thanks!!
Diego