在JSON数据表中单击按钮一次更改按钮属性

时间:2015-10-30 02:56:42

标签: javascript jquery json ajax

我有一个JSON数据表,它有数组对象和一个发送数据的按钮。因此,一旦单击按钮,该按钮应变为“btn-default”。问题是我在单独的ajax调用中执行它,如下所示,

$.getJSON('invoice/source/process/po_list_table.php', {vendId: vendId, jobId: jobId}, function (response) {

            // Initializes Button to Send to invoice list
            $.each(response, function() {
                this.sendButton = "<button class='btn btn-success btn-outline btn-xs' id='addToInvoice'>ADD</button>";
            });

            // Initialize DataTables for Listing PO
            var poTable = $('#listPoByJobTable').DataTable({
                paging: false,
                ordering: false,
                info: false,
                bFilter: false,
                processing: true,
                scrollY: "500px",
                scrollCollapse: true,
                data: response,
                destroy: true,
                oLanguage: {
                    "sSearch": ""
                },
                columns: [
                    {data: "PO_NO"},
                    {data: "sendButton"}
                ]
            });

            // Button function
            $('#listPoByJobTable tbody').on( 'click', 'button', function () {
                var data = poTable.row( $(this).parents('tr')).data();
                alert(data["PO_NO"]);
            });

            // Initialize AJAX onClick Data Send
            window.someGlobalOrWhatever = response.balance;
        });

因此,点击该按钮后,this.sendButton = "<button class='btn btn-success btn-outline btn-xs' id='addToInvoice'>ADD</button>应变为class='btn btn-default btn-outline btn-xs

请帮助我,因为我对如何做到这一点很困惑。感谢

0 个答案:

没有答案