/** * When site move to subdirectory, pictures, added in WYSIWYG, return old address * this small js fix it. */ (function($){ $(document).ready(function() { if (Drupal.settings.basePath != '/') { $("body.page-node article .entry-content img").each(function() { var src = $(this).attr('src'); $(this).attr('src', Drupal.settings.basePath + src); }); } }); })(jQuery.noConflict());
jQuery
In some cases we need to create some kind of online calculator without sending information to server. There are a lot of plugins but they are usefull only if we need to make serious calculations in simple cases we can use our brain and jQuery api. Code given below consist of two parts: html and js.
So html we need given below:
Sometimes we need to make some menu items non clickable, there are some modules in drupal wich can make it , but installing module is not the easiest solution. Couple js lines given below is easiest way as i think. This way is the best when we have dropdown menu with a lot of items in different levels, only in this case our solution is very suitable. Here is code:
Sometimes we are using different names of main jQuery function, i mean $ and jQuery. Finally it causes some errors with js code due to name differenses. we can prevent it using this construction jQuery.noConflict(). I will show in details how we should do it.