jquery UI datepicker 弹出位置样式自定义代码样例
2013-09-23 10:04
555 查看
向老外学习代码研究的真透彻。
quote:
First I think there should be a
would be also desirable, so you could set it and jquery modify it in case the dialog is rendered outside the viewport.
There's a "trick" to do this last thing. If you study the
before showing the dialog, Jquery will take it and will try to allocate the dialog in that position, and if it renders out of the screen, it will adjust it to make sure it is visible. Sounds good, eh?
Problem is;
But be careful of Jquery-ui updates, because a change in the internal implementation of the
mycode:
quote:
First I think there should be a
afterShowingmethod in the datepicker object, where you could change the position after jquery has done all its voodoo in the
_showDatepickermethod. Additionally, a parameter called
preferedPosition
would be also desirable, so you could set it and jquery modify it in case the dialog is rendered outside the viewport.
There's a "trick" to do this last thing. If you study the
_showDatepickermethod, you will see the use of a private variable
$.datepikcer._pos. That variable will be setup if nobody has set it up before. If you modify that variable
before showing the dialog, Jquery will take it and will try to allocate the dialog in that position, and if it renders out of the screen, it will adjust it to make sure it is visible. Sounds good, eh?
Problem is;
_posis private, but if you don't mind that. You can:
$('input.date').datepicker({ beforeShow: function(input, inst) { $.datepicker._pos = $.datepicker._findPos(input); //this is the default position $.datepicker._pos[0] = whatever; //left $.datepicker._pos[1] = whatever; //top } });
But be careful of Jquery-ui updates, because a change in the internal implementation of the
_showDatepickermight break your code.
mycode:
$('#<%= StartTime.ClientID%>,#<%= EndTime.ClientID%>').datetimepicker({ showSecond: true, timeFormat: 'hh:mm:ss', stepHour: 1, stepMinute: 1, stepSecond: 1, beforeShow: function (input, inst) { $.datepicker._pos = $.datepicker._findPos(input); //this is the default position // $.datepicker._pos[0] = whatever; //left $.datepicker._pos[1] = 46; //top inst.dpDiv.css('font-size' ,'30%'); }, }); | 不同浏览器样式不兼容,改用: beforeShow: function (a, b) { var cnt = 0; var interval = setInterval(function () { cnt++; if (b.dpDiv.is(":visible")) { var parent = b.input.closest("div"); b.dpDiv.position({ my: "left top", at: "left bottom", of: parent }); clearInterval(interval); } else if (cnt > 50) { clearInterval(interval); } }, 10); b.dpDiv.css('font-size','62.5%'); } |
相关文章推荐
- jquery-ui插件弹出框dialog自定义网页弹出位置
- jQuery UI datepicker用beforeShowDay给特殊日期添加样式以及常用的属性
- 解决 jQuery UI Datepicker 无法弹出
- 如何修改并自定义jquery ui datepicker的寬度
- 【点滴】-jquery.ui.datepicker指定任意位置显示
- Jquery ui datepicker设置日期范围,如只能隔3天【实现代码】
- Jquery ui datepicker设置日期范围,如只能隔3天【实现代码】
- jQuery UI Datepicker 一个案例(弹出div层,悬浮整个页面)
- jquery ui datepicker
- jquery.ui.datepicker 添加时分秒
- jQuery UI Datepicker使用介绍
- jQuery-ui 的datepicker日历插件使用clone()出来的input无法选择问题
- JQuery UI datepicker 使用方法
- jQuery-ui插件datepicker的参数使用详解
- jQuery UI Datepicker中文显示
- Jquery ui Datepicker 的汉化
- datetimepicker:jquery.ui.datepicker 添加时分秒
- jquery UI Datepicker时间控件的使用方法(终结版)
- jquery.ui.datepicker.js 用法
- JQuery 插件 ui.datepicker.js 中文日期输入框