I have a set of 5 sliders in a search form. The form shows on two
pages, one "static" and one that is loaded with AJAX (yes, I have to
do this because different pages should load depending on the url value
after #). The static works without any problem, but on the other page
where the content with the sliders are loaded with AJAX doesn't work.
When I try to call the function that should load them, my Firebug
displays the error "Control is not defined". I have included all the
scriptaculous files and prototype when the page loads.

The only difference is that instead of loading the function with body-
onload as on the "static" page, I load it from an img-onload in the
AJAX content (after the sliders html). I have also tried to load them
onComplete of the AJAX request without no luck.

On the AJAX loaded page it looks like this.
First the page loads with the scriptaculous and prototype files.

Then I load the content:

var myAjax = new Ajax.Request('index.php',{method: 'get', parameters:
'<?php echo$_SERVER['QUERY_STRING']; ?>', onComplete:
respSearchHTML});

The respSearchHTML function:

function respSearchHTML(originalRequest) {
  $('adContainer').innerHTML = originalRequest.responseText;
  loadSliders();
}

The loadSliders function:

function loadSliders(){
  var slider_rooms = new Control.Slider([$('slider-from_room'),$
('slider-to_room')], $('slider-rooms'), {
    spans:['span-rooms-selected'],
    startSpan:'span-rooms-start',
    endSpan:'span-rooms-end',
    range:$R(0, 20),
    step:1,
    restricted:true,
    values: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],
    sliderValue:[0, 20],
    onChange:function(v){$('from_rooms').value=v[0]; $
('to_rooms').value=v[1];},
    onSlide:function(v){$('from_rooms').value=v[0]; $
('to_rooms').value=v[1];}
    });

// and so on with the four other sliders...
}

The code works on a static page, but not when I try to execute the
loadSliders() function after I have got the AJAX content containg the
slider-divs on another page. Just the "Control is not defined" error.

Any suggestion why the sliders doesn't load and the error "Control is
not defined"?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to