[support] Jquery code revision...

Yani akayani at aapt.net.au
Mon Jun 10 15:30:11 UTC 2013


Great tool... I've not seen that one before. Thank you so much Jamie.

 

Yani

 

From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Jamie Holly
Sent: Friday, 07 June 2013 11:56 PM
To: support at drupal.org
Subject: Re: [support] Jquery code revision...

 

When Javascript encounters an error it will stop processing the rest of the
code, with the exception of asynchronous calls that were set before the
error and don't depend upon code in the global namespace. Here's a quick
example I threw together:

http://jsfiddle.net/HollyIT/n3r9Z/

As far as jQuery 1.8, it's very common for things to break when upgrading
jQuery. You might want to check the jquery_update module issues to see if
anything is being reported:

https://drupal.org/project/jquery_update



Jamie Holly
http://www.intoxination.net 
http://www.hollyit.net

On 6/7/2013 3:06 AM, Yani wrote:

I had a good look at this... (not that you are not absolutely right Dave)

 

The way I have done this is exactly how this works in using jQuery plugins.
The only difference I could detect was in the full use of jquery as opposed
to $.

 

There was an undefined var that occurred on some pages that I put inside a
'if' which solved the major issue being that the code broke the JS in the
IMCE file upload. I wouln't have thought an undefined var would break code
in other modules but there you go.

 

An outstanding issue now is that the code fails if I move from jQuery 1.7 >
1.8. That could well apply to other modules as well. Most likely I'll ignore
the issue, and at some point it will bite me again. J

 

Yani

 

 

 

 

From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Metzler, David
Sent: Tuesday, 04 June 2013 1:24 AM
To: support at drupal.org
Subject: Re: [support] Jquery code revision...

 

IN case no ones responded.  

 

The Drupal.beavoirs.mybehaviorname = {attach :Mycustomdocumentreadyfunction
}  is a direct replacement for the document.ready override. You should
always use this form in drupal to make sure that you don't have multiple
javascript files/functions overidding document.read.    Whether you move the
code up into  your zeroPoint behavior or whether you create a new behavior
on the Drupal.behaviors object is a matter of code organization and totally
up to you. 

 

Dave

 

From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Yani
Sent: Friday, May 31, 2013 7:32 PM
To: support at drupal.org
Subject: [support] Jquery code revision...

 

I need a hint on this... I've mentioned it before but couldn't get my head
around it and put it in the too hard basket. Of course it has come back and
bitten me again.

 

What's happening is my JS code is causing some other code to break.

 

There are 2 ways I've used the JS...

 


  _____  




(function($) {

  Drupal.behaviors.zeroPoint = {

    attach : function(context, settings) {

      //Drupal Jquery wrapper

      

 

Button items in here that call functions

 

      //end wrapper

    }

  }

})(jQuery);

// Note the wrapper is different for Drupal Behaviors

 


  _____  


 

function manageBlocks(menu) {( function($) {

    $(document).ready(function() {

      // jQuery wrapper

 

Functions actions in here

 

     //end wrapper

    });

  })(jQuery);

}

 


  _____  


 

Can I just lift the functions up and place them within the top section or do
I need to write the bottom section differently.

 

It just seems odd that this wouldn't be correct as is.

 

The sort of things it impacts are Facebook blocks that don't update and the
file upload MCE losses all JS abilities. 

 

Note... it's been 12 months since I've touched this and I'm most brain dead
on it!

 

 

Yani





 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20130611/214e8168/attachment.html 


More information about the support mailing list