jQuery Mobile DateBox插件仅在直接链接到页面时有效 [英] Jquery Mobile DateBox plugin only working when linked directly to page

查看:83
本文介绍了jQuery Mobile DateBox插件仅在直接链接到页面时有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用DateBox( http://dev.jtsage.com/jQM-DateBox/ )的插件,该页面具有最新版本的JqueryMobile,但正在发现一个奇怪的错误。
当我在index.html上打开我的应用并使用日期选择器在页面中导航至页面时,我得到了- http://cl.ly/19022K40472e3k0D0D2H

I am using the DateBox ( http://dev.jtsage.com/jQM-DateBox/ ) plugin for a page with the latest build of JqueryMobile but am finding an odd bug. When I open my app on index.html and navigate through the pages to the page with the date picker is I get this - http://cl.ly/19022K40472e3k0D0D2H

但是,如果我通过地址栏直接转到该页面,它将可以正常工作并按应有的方式显示。

However if I go direct to the page via the address bar it works fine and shows up as it should.

所以只是想知道还有其他人对此有疑问吗?或任何想法如何解决?

So just wondering is anyone else having problems with this? Or any idea how to fix it?

我还可以补充一点,有人知道如何在文本字段中显示当前日期吗?

Also I might add does anyone know how I can have the current date show in the text field?

谢谢。

推荐答案

1)好像是日期盒的CSS无法正确加载的问题。要加载CSS吗?在这种情况下,当您直接转到带有日期选择器的页面时,可能不会加载CSS。您可以使用firebug for firefox或Chrome中内置的开发人员工具检查是否已加载datebox css / Safari。(检查资源选项卡以查看所有加载的资源)

1) Looks like it is a problem with the css of datebox not being loaded properly.Are you loading the CSS of datebox in index.html?.In that case,when you directly go to the page with the datepicker,CSS might not be loaded.You can check if datebox css is loaded by using firebug for firefox or the in built developer tool in Chrome/Safari.(Check the resources tab to see all the loaded resources)

2)检查此示例- http://jsfiddle.net/BNsPB/ 。在此示例中,我将代码编写为文档就绪,在您的情况下,您可能必须在 pageinit pagecreate 中编写代码事件处理程序

2)Check this example - http://jsfiddle.net/BNsPB/. In this example I wrote the code in document ready,in your case you might have to write it in pageinit or pagecreate event handlers

在检查了您的实际代码之后,我认为您必须在pageshow事件处理程序中添加上述代码片段,如下所示:(假设bookingPage是页面的ID)

After checking your actual code I think you have to add the above code snippet in the pageshow event handler like this:(Assuming bookingPage is the id of the page)

$("#bookingPage").live( 'pageshow',function(event, ui){
  var today = new Date();
    var todayStr = today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate();
    $('#mydate').trigger('datebox', {'method':'set', 'value':todayStr});
     });
});

这篇关于jQuery Mobile DateBox插件仅在直接链接到页面时有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆