I'm using a asp.net slider inside an UpdatePanel within a page control.
I assign a behaviorID and call it using $find(behaviorID)
in both $(document).ready
and Sys.WebForms.PageRequestManager.getInstance().add_endRequest
functions inside a 开发者_如何学CJavaScript located in the bottom of the page.
The JavaScript function on the slider doesn't work after page_initial.
It fails to find the slider in JavaScript, i.e. $find(behaviorID) = null
. while other JavaScript functions set in the $(document).ready
does work.
However, I can view slider's rail and drag it.
But when I do any postback on the page with other controls , the slider works smoothly!
It generate additional tags with <... Class= ...Behavior_ID>
and the JS which is used to generate Slider and its Event in source code looks like:
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.SliderBehavior, {"Length":410,"Maximum":100,"Minimum":-100,"TooltipText":"Adjust Target","id":"targetSlider_JS"}, null, null, $get("ctl00_ContentPlaceHolder3_Target1_txtSlider"));
});
The page is in 'content' of a MasterPage. I guess it doesn't render the slider correctly when page-init, need some server side setting for slider?
Regards,
I had the same problem that was intermittent. Sometime it was null and other times was fine. I added a small setTimeout of 100ms to delay a call to $find and it works now.
didn't find solution.
used jquery slider instead.
精彩评论