I am very new to jQuery world, sorry if this is too basic a question. I have a jQuery function to create button dynamically:
function createButton(element, id, caption, leftPosition) {
if (element == null || element.length < 1) return;
var buttonTable = $("<table id='" + id + "'>");
buttonTable.addClass("togglebtn");
buttonTable.css("left", left);
var trow = $("<tr>");
$("<td>")
.text(cellText)
.data("buttonname", caption)
.click(function () {
//alert("Clicked Col=" + $(this).data("buttonname"));
TestButtonClick();
})
.appendTo(trow);
trow.appendTo(buttonTable);
buttonTable.appendTo(element);
}
Since this is a general method to create buttons, I want to add a click event to it so that the calling program can execute it's own method on click event. I mean I want to pass the client method name as parameter to createButton method which should eventually execute it on click. How is it possible to do and how to call the createButton method with that parameter?