jquery mobile datebox custom alignment

天大地大妈咪最大 提交于 2019-12-20 06:28:54

问题


I am currently using jquery mobile datebox (http://dev.jtsage.com/jQM-DateBox/) to display a calendar. I stuck the input in a div with display: none, and then I manually activate the calendar with the following javascript:

$('#opencalendarlink').live('click', function(){
    $('#datepicker').datebox('open');
});

where opencalendarlink is the id of the button and date picker is the id of the calendar. However, the calendar appears now left aligned, although the button and corresponding hidden div are center aligned. How can I fix this?


回答1:


Please try

    <div style="visibility:hidden; height: 0px;">
    <label for="mydate">Some Date</label>

    <input name="mydate" id="mydate" type="date" data-role="datebox"
       data-options='{"mode": "calbox"}'>
    </div>

jQM-DateBox calculates its position probably from it's parent and because it isn't rendered (because of the display:none) this will be 0,0, setting visibility will fix this



来源:https://stackoverflow.com/questions/8115541/jquery-mobile-datebox-custom-alignment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!