【问题标题】:DatePicker using CrossRider is not working?使用 CrossRider 的 DatePicker 不起作用?
【发布时间】:2012-12-18 07:49:30
【问题描述】:

使用 CrossRider,我想将 DatePicker 添加到页面的 DOM,这是我的代码:

appAPI.ready(function($) {
    appAPI.dom.addRemoteCSS('http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css');
    appAPI.dom.addRemoteJS('http://code.jquery.com/ui/1.9.2/jquery-ui.js');
    $('<input type="text" id="datepicker" />').prependTo($('body'), function(){$( "#datepicker" ).datepicker();});
});

但是没用,我也试过了

appAPI.ready(function($) {
    appAPI.dom.addRemoteCSS('http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css');
    appAPI.dom.addRemoteJS('http://code.jquery.com/ui/1.9.2/jquery-ui.js');
    $('<input type="text" id="datepicker" />').prependTo($('body'));
        $( "#datepicker" ).datepicker();
});

也没有成功,我试过了

appAPI.ready(function($) {
    appAPI.dom.addRemoteCSS('http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css');
    appAPI.dom.addRemoteJS('http://code.jquery.com/ui/1.9.2/jquery-ui.js');
    $('<input type="text" id="datepicker" />').prependTo($('body'));
    $('<script>$(function(){$("#datepicker").datepicker();});</script>').appendTo('head');
});

但是它们都不起作用,同时如果我们在简单页面上测试它会起作用吗?! 例如:

<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery UI Datepicker - Default functionality</title>
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>$(function(){$("#datepicker").datepicker();});</script>
</head>
<body>     
    <p>Date: <input type="text" id="datepicker" /></p>
</body>
</html>

如何使用 CrossRider 使日期选择器正常工作?

【问题讨论】:

    标签: javascript jquery jquery-ui jquery-ui-datepicker crossrider


    【解决方案1】:

    包含 jQueryUI 的最简单方法是通过 appAPI.resources.jQueryUI 方法使用 Crossrider 对 jQueryUI 的原生支持。

    【讨论】:

    • 方法appAPI.resources.jQuery 也被记录在案。不过,如果我在appAPI.ready 中使用appAPI.resources.jQuery('1.8.3');,我会得到Uncaught TypeError: appAPI.resources.jQuery is not a function。你能帮我解决这个问题吗?
    【解决方案2】:

    对于那些感兴趣的人,这里是解决方案:

    appAPI.ready(function($) {
        appAPI.resources.includeRemoteJS("http://code.jquery.com/ui/1.9.2/jquery-ui.js") ;
        appAPI.dom.addRemoteCSS("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/eggplant/jquery-ui.css");
        $('<input type="text" id="dateFrom" />').prependTo($('body'));
        $( "#dateFrom" ).datepicker();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-21
      • 2011-05-14
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多