G is undefined with multiple sliders

G is undefined with multiple sliders

Hi there!
I get a "g is undefined" message when trying to slide a slider that has been dinamycally added to the DOM.
In fact I'm using a function that places two sliders (they could be more) by running a for loop inside an array.
In this case the array has 2 elements so I get two sliders. Afterwords I try to get the value of one of them with the slide event inside a DIV but as soon as I click on the slider to start dragging, I get the "G is undefined" error on firebug.
Any hints about possible reasons?
  1.     $('#slider_'+name).slider(
        {
            min: range[0],
            max: range[1],
            value: cvalue,
            orientation: 'horizontal',
            step: 1,
            slide: function(e, ui)
            {
                $('#cvalue_'+name).val(ui.value);   
            }
        })