行內編輯 實現 ajax提交

//只能點擊一次
var can_click = true;
function Layui_edit(){
//數據可編輯
$(".My_edit").each(function(){
$(this).click(function () {
if(can_click) {
can_click = false;
var goodsid =this.dataset.id;
console.log(goodsid)
//變爲輸入框
var text = $(this).html();
$(this).html('<input type="text" class="layui-input layui-table-edit" value="' + text + '">');
$(this).children("input").val("").focus().val(text);

                //移除光標 恢復原樣
                $(this).find(".layui-table-edit").blur(function () {
                    // console.log($(this));
                    var data = $(this).val();
                    $(this).parent().html(data);
                    $(this).remove();
                    can_click = true;

                    ajax_("admin/Bankgoods/updatebankpoints", {id: goodsid,bankpoints:data}, function (r) {
                        success_res(r);
                    })
                })
            }
        })
    })

}
Layui_edit();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章