在隐藏的联系人表单上使用 jqTransform,选择框值不显示
抱歉,如果这很麻烦,但我真的可以在这里使用一些帮助:
http://dev。 rjlacount.com/treinaAronson-form/
单击左上角的“联系”按钮可以查看联系表单。我正在使用 jqTransform jQuery 插件来设置它的样式。它最初是通过 display:none; 隐藏的。应用于 ID 为“panel”的 div,并滑入以下内容:
$("#flip").click(function(e){
e.preventDefault();
$("#panel").slideToggle("3000");
});
通过此设置,联系人表单不会在其字段内显示选择框的当前值。如果我改为删除显示:无;我的 CSS 中面板 div 的规则,并在页面加载后隐藏表单:
$("#panel").hide();
表单显示正确。有谁知道我如何才能完成这项工作,并避免在页面加载后使用 jQuery 隐藏打开的面板时出现闪烁?
非常感谢您的任何建议。如果我可以提供更多信息,请告诉我。
Sorry if this is a pain the ass, but I could really use some help here:
http://dev.rjlacount.com/treinaAronson-form/
The contact form can be seen by clicking the "Contact" button on the top left. I'm using the jqTransform jQuery plugin to style it. It's hidden initially with display:none; applied to the div with the ID "panel", and slid in with the following:
$("#flip").click(function(e){
e.preventDefault();
$("#panel").slideToggle("3000");
});
With this setup, the contact form isn't displaying the current value of the select box inside its field. If I instead remove the display:none; rule for the panel div from my CSS, and hide the form after the page has loaded with:
$("#panel").hide();
The form display correctly. Does anybody know how I can make this work and avoid the flash of an open panel I get if I hide it with jQuery after the page loads?
Thanks so much for any advice. Please let me know if I can provide any more information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是, jqtransform 正在设置标签的宽度(转换后的选择中当前可见的值)以匹配原始选择的宽度。
如果原始 select(或其父级)设置了
display:none
,并且没有指定任何 css 宽度,则该元素上.width()
的结果为零。事实上,您可以检查(使用 firebug 或 google chrome 开发工具),这并不是联系表单没有显示选择元素的当前值,而是以宽度等于零的方式显示它。
对于您的情况,最简单的解决方案是为作为联系表单一部分的选择设置(在您的 css 文件中)固定宽度。这样,即使它们一开始会被隐藏,jqtransform 也会为标签设置正确的宽度。例如:
旁注:当然还有其他方法可以使其工作,包括调整 jqtransform 脚本以适合您的特定用例。与设置提到的标签宽度相关的脚本部分从第 289 行开始。
The problem is, jqtransform is setting width for a label (currently visible value in a transformed select) to match the width of original select.
If the original select (or its parent) has
display:none
set, and it doesn't have any css width specified, the result of.width()
on that element is zero.You can in fact check (using firebug or google chrome dev tools), that it's not that contact form isn't displaying the current value of the select element, but rather displaying it with a width equal to zero.
The easiest solution in your case, is to set (in your css file) fixed width for the selects that are part of a contact form. That way, even though they will be hidden at first, the jqtransform will set correct width for label. For example:
Side note: there are of course other ways to make it work, including tweaking the jqtransform script to fit your specific use case. Part of the script related to setting mentioned width of a label starts on line 289.