简体   繁体   中英

DatePicker using CrossRider is not working?

Using CrossRider, I want to add a DatePicker to page's DOM, here's my code:

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();});
});

But it didn't work, I also tried

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();
});

And it didn't work too, and I tried

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');
});

But none of them worked, meanwhile if we test this on simple page it will work ?! For example:

<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>

How to make the datepicker works using CrossRider ?

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

For those who are interested, here's the solution:

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();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM