Can someone point out to me how to make the ask class into a live click event.
$('.ask').jConfirmAction( {
question : "Are you sure you want to delete the selected row?",
yesAnswer : "Yes",
cancelAnswer : "No",
onYes: function(evt) {
contentpages(evt.target);
}
});
Unless its on this page:
/*
* jQuery Plugin : jConfirmAction
*
* by Hidayat Sagita
* http://www.webstuffshare.com
* Licensed Under GPL version 2 license.
*
*/
(function($){
jQuery.fn.jConfirmAction = function (options) {
var theOptions = jQuery.extend( {
question: "Are You Sure ?",
yesAnswer: "Yes",
cancelAnswer: "Cancel",
questionClass: "question",
yesClass: "yes",
cancelClass: "no",
onYes: function() {} // for specifying a function to call when the "yes" button is clicked
}, options );
return this.each( function() {
$(this).bind('click', function(e) {
e.preventDefault();
if($(this).next('.' + theOptions.questionClass).length <= 0) {
$(this).after('<div class="' + theOptions.questionClass + '">'+theOptions.question+'<br/><span class="' + theOptions.yesClass + '">'+theOptions.yesAnswer+'</span><span class="' + theOptions.cancelClass + '">'+theOptions.cancelAnswer+'</span></div>');
$( '.' + theOptions.yesClass ).bind('click', function( evt ) {
theOptions.onYes( evt );
$(this).parents( '.' + theOptions.questionClass ).fadeOut( 300, function() {
$(this).remove();
} );
});
$( '.' + theOptions.cancelClass ).bind('click', function(){
$(this).parents( '.' + theOptions.questionClass ).fadeOut( 300, function() {
$(this).remove();
} );
});
}
$(this).next( '.' + theOptions.questionClass ).animate( { opacity: 1 }, 300 );
});
} );
}
})(jQuery);
If you do not want to change the code for the plugin simply initialise it after you put “.ask” elements in the page. e.g.
If you want the plugin to register events on non existant elements you need to modify it to take a selector name as a parameter and generally registering the live event – this is a quick and dirty way
and you initialise it like so