Here is a simple jQuery script which could use the validate a mandatory input.
(function ($) {
$(document).ready(function() {
$('#<submit-button-id>').click(function(event){
var x = $('<input-id>').val();
if (x == null || x == '';) {
alert('Please fill in the input.');
event.preventDefault();
}
})
});
})(jQuery);
Cycle Plugin is the most common plugin which could be found in my projects. This article shows you how to customize the pager of the Cycle Plugin slide show.
I have a HTML div which will be shown from hidden to visible by changing the opacity with jQuery animate(). It works fine in normal browser like Chrome and Firefox. But from the abnormal browser like Internet Explorer, the font/text is distorted.
Internet Explorer has problem with opacity and font antialiasing in animate(). A workaround is to remove the opacity after the animation is completed.
jQuery UI is included in Drupal 7 core. By default it is not included in every page, so if u want to implement those jQuery UI features, here is the little tricks you need.
Today i will continue the example written by Kevin Hankens and make the module more secure. We want to add a token in the Ajax request such that the server could check if it comes from a valid user. This token could be obtained from drupal_get_token() which will return a fixed token value for each user session. Here are the list of changes in the new eureka_ajax.module.
Set the token value in Drupal.settings in hook_init()
Add the token as query string in the theme_ajax_link()
Check if the token is valid in ajax_request_callback()
In this post, i will show you how to implement a simple Ajax function in Drupal 7. The following example code is based on the blog post written by Kevin Hankens about implementing Ajax in Drupal 6. Kevin Hankens’s blog – Drupal, jQuery and $.ajax() easyness