Tag Archives: Code

Dojo and jQuery part 2

Part 2 should have been some more examples but I feel that I need to write some about the response on my first part there where alot of comments discussing different things around Dojo vs jQuery.

First I like to say that my compare between these two was to show that you can do the same things with Dojo as you can do with jQuery and the code does look almost the same, also that Dojo has so much more inside the “package”. 

Joacim wrote why are you comparing an older version of Dojo than jQuery well because I´m mainly working with Dojo and xPages and the Domino server currently has an old version of Dojo and jQuery would be an addon to the server and then be of the latest version. But also to point out that even though Dojo 1.6 is 2 releases old you still can still use it and it will work great, and there is no need for jQuery. If you should learn one client side library it´s Dojo because this is what IBM is using for all the things in XPages.

I will continue with my Dojo travel in part 3 and that one will include some code I promise 😉

HTML manipulation Dojo vs jQuery

I have seen some writing by TexasSwede about how to use jQuery for manipulating the DOM and it seams easy but why import another toolkit for manipulating the DOM? Well perhaps if you know jQuery that might be the case or that you think jQuery is better. 

Let’s compare jQuery vs Dojo for some simple DOM changes. I’m using the latest jQuery 1.9 vs Dojo 1.6, why not the latest version well because XPages currently has 1.6 and because 1.8 has a different syntax.

let’s add the class pretty to every a tag in the page

 jQuery

  $("a").each( function() {
    var tag=$(this);
    tag.addClass('pretty');
  }

Dojo

 dojo.query("a").forEach(function(node, index, arr){
      node.addClass("pretty")
  });

The code is quite similar in both Dojo and jQuery, I don’t know about speed perhaps some of you readers know?

I’ll move forward in part 2 with some more Dojo stuff, stay tuned.

PS!Don’t forget to change your email signature

Sent from Lotus Notes – More than an inbox  

Get a progressbar everytime a partialrefresh is fired

I was looking for some code today to get a wait sign when a partial refresh had fired. I found this great article at lotusnotus.com bu that wait sign had to be added to each event (Not my kind of thing 😉 ).

Then I remembered that I saw some code created by Tommy Valand to hijack all partial refresh events.

So I made a cut and paste coding and volia. Standby wait sign every time a partialrefresh fires.

I added code section one and two above and also this section into a scriptlibrary.

You could add this lib to a custom control and add the hijackAndPublishPartialRefresh() function in the onclientload client event. Also add dojox.widget.Standby as a dojo module resource.

When I started to use this I found that it was firing all the time, and I didn’t want that so I did some modifications

You’ll still need the hijack script and this last script.

Enjoy!!

Update, Latest version of this can be found here
using the designer import tool –> Link

Or XSnippet