x可编辑的重置字段 [英] x-editable resetting fields

查看:138
本文介绍了x可编辑的重置字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下html / php代码(php tag ommited)

i have the following html/php code (php tag ommited)

$user = array(
    'name' => Null,
    'address' => Null
);  

<div id="user">
    <a href="#"  id="cust_name" data-type="text"
         data-pk="'.$user['ag_id'].'" title="Enter customer name">'.$user['name'].'</a>
    <a href="#"  id="cust_addr" data-type="text"
         data-pk="'.$user['ag_id'].'" title="Enter customer address">'.$user['address'].'</a>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" id="ResetButton">Reset</button>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="SaveButton"
             data-dismiss="modal">Save changes</button>
    </div>
</div>



< ..这里是脚本

could you please complete my resetbutton script, the purpose is to assign null to cust_name and cust_addr after the click.. here's the script

<script>
    $.fn.editable.defaults.mode = 'inline';

    $(function(){
        $('#user a').editable({
           url: 'post.php' 
        });
    });

    $("#SaveButton").click(function() {
        $.ajax({
            url: 'db.php',
            type: 'POST',
            data: {}
        });
    });

    $('#ResetButton').click(function() {
        // $('#cust_name').editable('setValue', null); // did not worked            
        // didn't worked even i added class="myeditable" in my <a> tag
        /*
        $('.myeditable').editable('setValue', null)
           .editable('option', 'pk', null)
           .removeClass('editable-unsaved');
        */
    });

</script> 


推荐答案

这似乎有效。

http://jsfiddle.net/U33kT/

我不知道有什么区别,除了我选择了所有可编辑的内容(JS第6行):

I'm not sure the difference, except that I chose all editables (JS line 6):

$('#user a').editable('setValue', null);

但是,我尝试使用单个项目:

But, I tried with single items:

$('#cust_name').editable('setValue', null);

它似乎也可以工作。

希望这有帮助。

这篇关于x可编辑的重置字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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