x-editable resetting fields
Asked Answered
D

1

3

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> 
Daniel answered 2/12, 2013 at 14:22 Comment(0)
S
3

This seemed to work.

http://jsfiddle.net/U33kT/

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

and it seemed to work as well.

Hope this helps.

Shogun answered 22/1, 2014 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.