admin管理员组文章数量:1335356
I have Kendo window that has a scrollbar. If the user scrolls down to the bottom of the window content, closes the window, and then reopens, the window opens with in the same scroll position (i.e. at the bottom of the window content). However, I would like for the window to always display back at the top of the content on reopening. How can this be done?
Here's the jsfiddle demonstrating the issue:
/
Here's some code from the fiddle since I have to include this for the post to work...
var win;
function openWindow() {
if (!win) {
win = $('#win').kendoWindow({
modal: true,
width: '100px',
height: '100px'
});
}
$('#win').css('display', '');
win.data('kendoWindow').center().open();
}
$(document).ready(function() {
$('#button').click(openWindow);
});
I have Kendo window that has a scrollbar. If the user scrolls down to the bottom of the window content, closes the window, and then reopens, the window opens with in the same scroll position (i.e. at the bottom of the window content). However, I would like for the window to always display back at the top of the content on reopening. How can this be done?
Here's the jsfiddle demonstrating the issue:
http://jsfiddle/e6shF/24/
Here's some code from the fiddle since I have to include this for the post to work...
var win;
function openWindow() {
if (!win) {
win = $('#win').kendoWindow({
modal: true,
width: '100px',
height: '100px'
});
}
$('#win').css('display', '');
win.data('kendoWindow').center().open();
}
$(document).ready(function() {
$('#button').click(openWindow);
});
Share
Improve this question
edited Jan 18, 2013 at 23:59
OnaBai
40.9k6 gold badges97 silver badges125 bronze badges
asked Jan 18, 2013 at 22:51
JamesJames
3,19421 gold badges78 silver badges129 bronze badges
1 Answer
Reset to default 5To scroll your <div id="win">
back to the top position just run:
$("#win").scrollTop(0);
after reopening it:
var win;
function openWindow() {
if (!win) {
win = $('#win').kendoWindow({
modal : true,
width : '100px',
height: '100px'
});
}
$('#win').css('display', '');
win.data('kendoWindow').center().open();
$('#win').scrollTop(0);
}
$(document).ready(function() {
$('#button').click(openWindow);
});
or if you want to simplify your code:
$(document).ready(function () {
function openWindow() {
win.center().open();
win.element.scrollTop(0);
}
var win = $('#win').kendoWindow({
visible: false,
modal : true,
width : '100px',
height : '100px'
}).data("kendoWindow");
$('#button').click(openWindow);
});
本文标签:
版权声明:本文标题:javascript - How can I have a Kendo window with a scrollbar open with a scrollTo(0,0)? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742368946a2461843.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论