jquery slider .on()

lonphatays

New Member
I have the following jquery code:\[code\] $('div#headBannerSearchAgedBetweenSlider').slider({ range: true, min: 18, max: 99, values: [18, 65], change: function(event, ui) { $('span#headerBannerAgedMin').html(ui.values[0]); $('span#headerBannerAgedMax').html(ui.values[1]); }, slide: function(event, ui) { if (ui.values[0] == ui.values[1]) {return false;} } });\[/code\]The catch is the element 'div#headBannerSearchAgedBetweenSlider' is not avalible when the js script is loaded so I need to use something like .live() or .on() to attach the slide event once the element is avaliable.How do I bind slide to the element 'div#headBannerSearchAgedBetweenSlider' once its visible? I tried to wrap the code in the following (using $(this) as the element but I'm not using a click event. I just needs to bind once the element exists.\[code\] $(document).on('click','div#headBannerSearchAgedBetweenSlider', function() { });\[/code\]How do I do this? thankyouI have tried the following .ready() without luck - is there anything obviously wrong with this?\[code\]$('div#headBannerSearchAgedBetweenSlider').ready(function() { $('div#headBannerSearchAgedBetweenSlider').slider({ range: true, min: 18, max: 99, values: [18, 65], change: function(event, ui) { $('span#headerBannerAgedMin').html(ui.values[0]); $('span#headerBannerAgedMax').html(ui.values[1]); }, slide: function(event, ui) { if (ui.values[0] == ui.values[1]) {return false;} } });});\[/code\]
 
Back
Top