Chaos Tool Suite is one of the best API module to use. The module mainly provides API.
I've worked on ctools before to create multi-step form and show that in popup. This time I'm working on a project which has a Quiz in it which is built using ctools. The site was having a requirement of displaying Quiz form when user clicks on link from E-Mail.
So to display ctools modal on page load we've to add below jQuery Code:
Drupal.ajax.prototype.moduleName = function() {
var ajax = this;
// Do not perform another ajax command if one is already in progress.
if (ajax.ajaxing) {
return false;
}
try {
$.ajax(ajax.options);
} catch (err) {
alert('An error occurred while attempting to process ' + ajax.options.url);
return false;
}
return false;
};
/**
* Define a point to trigger our custom actions. e.g. on page load.
*/
$(document).ready(function() {
// Since we need to display the modal only if below setting is set.
if (!$.isEmptyObject(Drupal.settings.moduleName)) {
Drupal.ajax[$('a.quiz-button').attr('href')].moduleName();
}
});
.quiz-button is class of link for user to start the Quiz.
var ajax = this;
// Do not perform another ajax command if one is already in progress.
if (ajax.ajaxing) {
return false;
}
try {
$.ajax(ajax.options);
} catch (err) {
alert('An error occurred while attempting to process ' + ajax.options.url);
return false;
}
return false;
};
/**
* Define a point to trigger our custom actions. e.g. on page load.
*/
$(document).ready(function() {
// Since we need to display the modal only if below setting is set.
if (!$.isEmptyObject(Drupal.settings.moduleName)) {
Drupal.ajax[$('a.quiz-button').attr('href')].moduleName();
}
});