从Datebox到Jquery清除日期 [英] Clear Date from Datebox through Jquery

查看:84
本文介绍了从Datebox到Jquery清除日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码显示了日期框模式弹出窗口中的一个按钮,但我希​​望清除我点击按钮的日期。我尝试过很多东西但是不能用jQuery方法做到这一点。

This below code is showing a button in datebox modal popup but I want clear the date when I will click on the button. I tried lots of things but not able to do it by jQuery method.

 <zk>
    <script>
    zk.afterLoad('zul.db', function () {
    var _xRenderer = {};
    zk.override(zul.db.Renderer, _xRenderer, {
    titleHTML: function (wgt, out, localizedSymbols) {
    _xRenderer.titleHTML.apply(this, arguments); //call the original method
    var uuid = wgt.uuid,
       view = wgt._view,
       text = wgt.getZclass() + '-ctrler';

    if(view == 'day') {
    out.push('&lt;button id="', uuid, '-today" class="', text, '"', 
    ' onClick="var cal = zk.Widget.$(\'$', wgt.parent.id, '\')._pop; cal._value = null; cal._setTime();"',
    ' &gt;', ' today', '&lt;/button&gt;');
    }
              out.push('&lt;button id="', uuid, '-clear" class="', text, '"', 
    ' onClick="alert(jq(this.parent.$n()))"',
    ' &gt;', ' clear', '&lt;/button&gt;');
    }
    });
    }); 
    </script>
    <datebox id="db" ></datebox>
    </zk>


推荐答案

在你的情况下,清除按钮是一个孩子dom日期框但不是子窗口小部件,this.parent。$ n()仅在按钮是日期框的子窗口小部件时才有效。

In your case, the clear button is a child dom of datebox but not a child widget, this.parent.$n() only works if button is a child widget of datebox.

您可以修改它以使其工作如下所示:

You can modify it to make it work as below:


  1. 从弹出日历中获取datebox的id(id为datebox id +' - pp')。

  2. 获取带有id的datebox小部件。

  3. 清除datebox的输入节点的值,然后调用datebox的updateChange_方法。

我稍微修改了您的样本:

I have slightly modified your sample:

<zk>
    <script><![CDATA[
    zk.afterLoad('zul.db', function () {
    var _xRenderer = {};
    zk.override(zul.db.Renderer, _xRenderer, {
    titleHTML: function (wgt, out, localizedSymbols) {
    _xRenderer.titleHTML.apply(this, arguments); //call the original method
    var uuid = wgt.uuid,
       view = wgt._view,
       text = wgt.getZclass() + '-ctrler';

    if(view == 'day') {
    out.push('<button id="', uuid, '-today" class="', text, '"', 
    ' onClick="var cal = zk.Widget.$(\'$', wgt.parent.id, '\')._pop; cal._value = null; cal._setTime();"',
    ' >', ' today', '</button>');
    }
              out.push('<button id="', uuid, '-clear" class="', text, '"', 
    ' onClick="clearDatebox(this)"',
    ' >', ' clear', '</button>');
    }
    });
    });
    function clearDatebox (btn) {
        var id = jq('.z-datebox-pp')[0].id.replace('-pp', ''),
            dbx = zk.Widget.$('#' + id);
        dbx.getInputNode().value = '';
        dbx.updateChange_();
    }
    ]]></script>
    <datebox id="db" ></datebox>
</zk>

这篇关于从Datebox到Jquery清除日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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