Reputation:
I have jquery button which need click event to enable the datatable.Please look into below code advise.
jQuery( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 750,
modal: true,
buttons : {
"Search" : function() {
jQuery.ajax({type : 'POST',
url : ' <s:url action="part" method="list" /> '
})
}
}
});
Now i need to write Search button click event.
jQuery("Search").click(function() { Hello });
Above event is not triggering.What is the issue here ?
Upvotes: 2
Views: 221
Reputation: 21482
You don't need to attach an event handler to the "Search" button using .click()
. The function that gets executed when the button is clicked is the function you specify in the "buttons" option. In your case, the function that gets executed when the "Search" button is clicked is:
function() {
jQuery.ajax({
type: 'POST',
url : '<s:url action="part" method="list" />'
})
}
Just change that function to what you want it to be.
Upvotes: 0
Reputation: 51927
It should be either
//really concise and great if you're not passing parameters
jQuery("#Search").on('click', Hello);
or
// you had Hello instead of Hello();
jQuery("#Search").on('click', function() { Hello(); });
Use .on() for dynamic code.
Upvotes: 2
Reputation: 104775
This selector jQuery("Search")
is searching for an element of Search
. If Search
is an ID you need to use the ID #
selector:
jQuery("#Search").click(function() { console.log("hello"); });
Also, inside your click function, I'm not sure what Hello
is, but I presume you wanted an alert or a log.
Upvotes: 0