Posts

Showing posts from January, 2017

Overriding Drupal JS function on the fly

Sometimes it is necessary that we solve some JS issues without making new deployment in production. Following example overrides the viewScrollTop JS function (originates from views module). The following code has to be added in AddToHead module of Drupal in the page-bottom section. <script> (function(Drupal, $) {     Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {  // Scroll to the top of the view. This will allow users  // to browse newly loaded content after e.g. clicking a pager  // link.  var offset = $(response.selector).offset();  // We can't guarantee that the scrollable object should be  // the body, as the view could be embedded in something  // more complex such as a modal popup. Recurse up the DOM  // and scroll the first element that has a non-zero top.  var scrollTarget = response.selector;  while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).p...

General Knowledge Base

Bash: cmd.exe C:\xampp\mysql\bin mysql -u root -p --force test2 < C:\Users\rgopi\Downloads\test.sql Ajax:  If you want to do ajax actions on form elements, attach #ajax property in form field definitions. For example, when you use #ajax in an select field, #ajax automatically adds onChange() event to ajax. #ajax support following important parameters #ajax['callback'] => The callback is a function which returns a renderable array which consists of html or ajax commands. #ajax['wrapper']: The CSS ID of the area to be replaced by the content returned by the #ajax['callback'] function. The content returned from the callback will replace the entire element named by #ajax['wrapper']. The wrapper is usually created using #prefix and #suffix properties in the form. Ajax in menu callbacks: If you want to perform ajax actions on menu call backs. Use ajax_deliver. It packages and sends the result of a page callback as an A...