jquery datepicker 部分不工作

发布于 2024-11-03 03:27:19 字数 1883 浏览 1 评论 0原文

你好,我有一个可以完美单独工作的日期选择器,代码如下:

 <link rel="stylesheet" href="uidatepicker/themes/blitzer/jquery.ui.all.css">
    <script src="uidatepicker/jquery-1.5.1.js"></script>
    <script src="uidatepicker/jquery.ui.core.js"></script>
    <script src="uidatepicker/jquery.ui.widget.js"></script>

    <script src="uidatepicker/jquery.ui.datepicker.js"></script>
    <link rel="stylesheet" href="uidatepicker/demos.css">


    <script>
    $(function() {
        $( "#datepicker" ).datepicker({
            showOn: "both",
            buttonImage: "uidatepicker/calendar.gif",
            buttonImageOnly: true
        });
    });
    </script>


<form method="post" action="saveEvent.php">
<p>Titulo del evento:</p>
<input type="text" name="title" value=""  class="text-input medium-input datepicker"/>
<p>Descripcion:</p>
<textarea name="message"></textarea>
<p>Fecha:</p>
<input type="text" name="date" value="" id="datepicker"/>
<p>Locacion:</p>
<select name="locationId" class="small-input">
  <option value="">--- Selecciona ---</option>
            <option value="3">La charanguita</option>
            <option value="7">H20</option>
            <option value="8">Bleu</option>
      </select>
<p>Url del icono: (150x135px)</p>
<input type="text" name="smallIconUrl" value=""  class="text-input medium-input"/>

<p><input type="submit" value="Nuevo Evento" class="button"  /></p>

</form>

我从另一个文件加载它,如下所示:

    $('#EventsContent').load('partials/newEvent.php');

问题是,无论我尝试什么,日期选择器都不会出现,这对我来说已经钉了三天了。

阻碍 jquery ui datepicker 正确操作的确切问题是什么??+

提前感谢您的帮助。

hello i have a datepicker that is working perfectly alone, code is like:

 <link rel="stylesheet" href="uidatepicker/themes/blitzer/jquery.ui.all.css">
    <script src="uidatepicker/jquery-1.5.1.js"></script>
    <script src="uidatepicker/jquery.ui.core.js"></script>
    <script src="uidatepicker/jquery.ui.widget.js"></script>

    <script src="uidatepicker/jquery.ui.datepicker.js"></script>
    <link rel="stylesheet" href="uidatepicker/demos.css">


    <script>
    $(function() {
        $( "#datepicker" ).datepicker({
            showOn: "both",
            buttonImage: "uidatepicker/calendar.gif",
            buttonImageOnly: true
        });
    });
    </script>


<form method="post" action="saveEvent.php">
<p>Titulo del evento:</p>
<input type="text" name="title" value=""  class="text-input medium-input datepicker"/>
<p>Descripcion:</p>
<textarea name="message"></textarea>
<p>Fecha:</p>
<input type="text" name="date" value="" id="datepicker"/>
<p>Locacion:</p>
<select name="locationId" class="small-input">
  <option value="">--- Selecciona ---</option>
            <option value="3">La charanguita</option>
            <option value="7">H20</option>
            <option value="8">Bleu</option>
      </select>
<p>Url del icono: (150x135px)</p>
<input type="text" name="smallIconUrl" value=""  class="text-input medium-input"/>

<p><input type="submit" value="Nuevo Evento" class="button"  /></p>

</form>

and i am loading it from another file as in:

    $('#EventsContent').load('partials/newEvent.php');

Problem is datepicker never appears no matter what i tried, this has been nailing for me for like 3 days now.

What is the exact problem impeding the correct operation of jquery ui datepicker??+

Thanks in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分开我的手 2024-11-10 03:27:19
  1. 您使用哪种输入文本日期选择器?我看到你有一个 id="datepicker " 和 class="datepicker "?

  2. 我将 ' 替换为 " ,我在浏览器“IE,FireFox,GoogleChrome”中测试代码,它可以工作。

  3. 我使用 JQuery 1.5.2 和jquery-ui-1.8.10,不过我觉得版本问题不大。

4.我有另一个理想,你可以在加载完整时重新绑定datepicker事件,如下所示:

$('#EventsContent').load('partials/newEvent.php', function() {
    $( "#datepicker" ).datepicker({
        showOn: "both",
        buttonImage: "uidatepicker/calendar.gif",
        buttonImageOnly: true
    });    
});

当你加载partial后使用datatpicker时,你必须重新绑定,但是JQuery live()函数可以帮助我们执行此操作,请参阅 http://api.jquery.com/live/

<script type="text/javascript">
    $(function () {
        $("#datepicker").live("click", function () {
            $(this).datepicker({
                showOn: "both",
                buttonImage: "uidatepicker/calendar.gif",
                buttonImageOnly: true
            }).focus();
        });
    });
</script>

而不是:

$(function() {
    $( "#datepicker" ).datepicker({
        showOn: "both",
        buttonImage: "uidatepicker/calendar.gif",
        buttonImageOnly: true
    });
}); 
  1. which input text you use datepicker? I saw you have an id="datepicker " and class="datepicker "?

  2. I replace the ' to " , I test the code in browser "IE,FireFox,GoogleChrome", it's work.

  3. I use JQuery 1.5.2 & jquery-ui-1.8.10, but I think version is not a big problem.

4. I have the other ideal, you can re-Bind the datepicker event when you load complete like this:

$('#EventsContent').load('partials/newEvent.php', function() {
    $( "#datepicker" ).datepicker({
        showOn: "both",
        buttonImage: "uidatepicker/calendar.gif",
        buttonImageOnly: true
    });    
});

When you use the datatpicker after you load the partial , you must re-bind, but JQuery live() function can help us to do that things, see http://api.jquery.com/live/

<script type="text/javascript">
    $(function () {
        $("#datepicker").live("click", function () {
            $(this).datepicker({
                showOn: "both",
                buttonImage: "uidatepicker/calendar.gif",
                buttonImageOnly: true
            }).focus();
        });
    });
</script>

instead of :

$(function() {
    $( "#datepicker" ).datepicker({
        showOn: "both",
        buttonImage: "uidatepicker/calendar.gif",
        buttonImageOnly: true
    });
}); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文