views:

155

answers:

2

I get the impression mootools will do this, but in a roundabout way.

I am working with livevalidation script. What I want to achieve is when the from runs and errors are generated then the page will scroll to the first error found. This will be outputted as:

<span class=" LV_validation_message LV_invalid">Can't be empty!</span>

with jquery I could do the following:

$.scrollTo($('span.LV_invalid:1'));

I get the feeling in mootools I have to first find the position of the first span with class LV_invalid then pass this to the scrollTo function or is there a much simpler solution?

A: 

Do validation, and use SmoothScroll - http://docs111.mootools.net/Plugins/SmoothScroll.js

Oskar Krawczyk
A: 

figured this one out

var  scroll =  new Fx.Scroll(window,  { 
    wait: false, 
    duration: 1500, 
    transition: Fx.Transitions.Quad.easeInOut  
  }); 
  var xcoord = $$('.LV_invalid').getPosition()[0].x;
  var ycoord = $$('.LV_invalid').getPosition()[0].y;
  scroll.scrollTo(xcoord,ycoord);
Dtour