滚动到打开的jQuery对话框中具有类的最后一行 [英] Scroll to last row having class in jQuery Dialog on open
问题描述
使用长表填充jQuery UI对话框,我希望它滚动到具有特定类的表的最后一行.我发现另外两个帖子几乎与此这里和此处,但我无法理解去工作.我在 jsFiddle 中对其进行了模拟,希望有人可以帮助我看看我的错误.考虑一下.
Populating a jQuery UI Dialog with a longish table, I would like to have it scroll to the last row in the table having a specific class. I found two other posts almost identical to this here, and here, but I can't get it to work. I've mocked it up at jsFiddle in the hope that someone might help me see the error in my thinking on it.
这是基本代码
jQuery(document).ready(function() {
var content = jQuery('#amtz_div').html();
var title = 'Amortization Schedule';
var open = function() {
var container = jQuery(".ui-dialog");
var target = jQuery('tr.amortized:last');
container.scrollTop(target.offset().top - container.offset().top + container.scrollTop());
target.css('background', 'red');
}
jQuery("#dialog").attr('title', title).html(content).dialog({
modal: true,
width: 400,
height: 400,
resizable: false,
open: open
});
});
我也尝试了scrollTo插件(在上面链接的文章之一中提到),但是现在更好了.
I also tried the scrollTo plugin (mentioned in one of the post linked above) but had now better luck with that.
有什么想法吗?
推荐答案
我不确定它是否是jQuery UI
的新版本,或者我们是否已经离开了,但是将标识符从.ui-dialog更改为#在您的情况下进行对话.我要看看这是否也适合我!
i'm not sure if it's the new version of jQuery UI
or that we have been away from this but changing the identifier from .ui-dialog to #dialog work in your case. I'm going to see if this works for me as well!
这篇关于滚动到打开的jQuery对话框中具有类的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!