Click event not firing in frappe.ui.Dialog

Hi Friends, wanting to customise dialog by converting it to a grid/table of rows so user can select multiple profiles and confirm see screen shot. I cannot get the confirm button to fire see (submit.click) . I also noticed that the AJAX call is not firing on fail -success does not work, have not implemented yet- it does not call someFunction. any help please.

here is the code

/* ADD A BUTTON */

refresh: function (frm) {
frm.add_custom_button(“do somehing”, function () {

/* BUILD THE GRID-TABLE */

        var mytable = $("<table></table>").attr({id: "basic"});
        var tblBody = $("<tbody></tbody>").attr({id: "tblProfile"});
        var row_count = 4;
        var col_count = 4;

        for (var row = 0; row < row_count; row++) {
            var tr = $("<tr></tr>").attr({class: "rowKK"});
            var inputContainer = $("<td></td>");
            inputContainer.append($('<input>', {id: "cb", type: "checkbox", name: "cb"}));
            tr.append(inputContainer);

            for (var col = 0; col < col_count; col++) {
                var cell = $("<td></td>");
                var cellText = cell.append(document.createTextNode("r" + row + "c " + col));
                cell.appendTo(tr);
            }
            tr.appendTo(tblBody);

        }

        var submitAndDiv = $("<div></div>").append($('<input>', {
            id: "submit12",
            type: "submit",
            name: "submit12",
            value: "Confirm1"
        }));

/* COLLECT CHECKED BOXES SELECTED */

        var submit = submitAndDiv.find("input");

        submitAndDiv.appendTo(tblBody);

        submit.click = function () {
            console.log("here");
            user_selection = {
                results: []
            };

            data = [];
            datalines = $("input[name='cb']:checked").siblings("td");
            $.each(datalines, function () {
                data.push($(this).text());
                data.map(function (item) {
                    user_selection.results.push({
                        "col": item
                    });
                });
            });
            //populate(user_selection);
            return false;
        };


        tblBody.appendTo(mytable);

        profile = document.getElementById("tblProfile");

/* AJAX CALL HERE */

        function doAjax(url, data, success, callback) {


                .fail(
                    function (callback) {
                        callback = "hhhh";
                        someFunction(callback);
                        return callback;
                    })
                .success(
                    function (callback) {
                        callback = "hhhh";
                        someFunction(callback);
                        return callback;
                    })
        }

        function someFunction(callback) {
            alert(callback);
        }     

        var dialog = new frappe.ui.Dialog({
            title: __("Customer Profile"),
            fields: [{'fieldname': 'today', 'fieldtype': 'Date', 'default': frappe.datetime.nowdate()},
                {"fieldname": "ht", "fieldtype": "HTML"},
                {"fieldname": "ConfirmBtn", "fieldtype": "HTML"}
            ]
        });
        dialog.fields_dict.ht.$wrapper.html(mytable.html());
        dialog.fields_dict.ConfirmBtn.$wrapper.html(submit);
        dialog.show();
    });
}

It is very hard to debug like this. Maybe we need a jsfiddle like tool to setup a demo!

If you state your exact problem, very briefly, it will help.

Hi rmehta, yes sure, I wanted to add a popup that displays a list of profiles from the database. So my choice was to use frappe.ui.dialog, add the profile list as cells in rows, the first cell in each row is a checkbox. So I did that and called “dialog.fields_dict.ht.$wrapper.html(mytable.html());” to draw the table as shown in picture. I then used
dialog.fields_dict.ht.$wrapper.html(submit); to add a button (confirm) so we can collect the user selection of profiles and pass the data to the doctype customer. The problem I am having is that the submit button not firing on click even though I attached a click event. how do I get it to fire?

Ok I resolved it, I was passing the wrong field type for the button. I shall post the code here once it is all working. Thanks