Tag Archives: jQuery

Update to infinite scrolling snippet

Ferry did write a great snippet to get infinite scrolling in views posted on openntf xsnippets but lately I found that this had stopped working on some server versions. So I did some changes to get this to work on all versions

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
 
  <!-- make sure 'add rows' component is hidden -->
  <style>
    .infiniteScroll{display:none;}
  </style>
   
  <!-- add a class for the 'add rows component'  -->
  <xe:pagerAddRows id="pagerAddRows1"
    for="#{javascript:compositeData.repeatId}"
    styleClass="infiniteScroll">
  </xe:pagerAddRows>
 
   
  <!-- small script to check if we need to auto-click the 'add rows' button -->
  <xp:scriptBlock id="scriptBlock1">
    <xp:this.value><![CDATA[$(window).scroll(function(){
    if($(window).scrollTop() == $(document).height() - $(window).height()) {
      if($(".infiniteScroll ul li span").length!=0){
         $(".infiniteScroll ul li span")[0].click();
      }
      if($(".infiniteScroll ul li a").length!=0){
       $(".infiniteScroll ul li a")[0].click();
     }
   }
});]]></xp:this.value>
  </xp:scriptBlock>
</xp:view>

The changes is in the script block where I added a check if we find the span or the a tagg and if that we do a click on the first element found. This is because I didn’t get it to work using JQuerys ordinary click function.

Update of the Bootstrap standby widget

a minor update to fix some issues with the standby widget for bootstrap is in xSnippets.
Found an issue with multiple triggering of the widget, this is hopefully fixed now, reported by David Leedy.

Check it out here

https://openntf.org/XSnippets.nsf/snippet.xsp?id=bootstrap-standby-dialog

Another great developer book found

Summer is here and book reading time for me is also here, I’ve read and added this great resource to my desk at work, JQuery and Javascript Phasebook.

JQuery And JavaScript Phasebook

I often like to have all my resources as pdf files but in some cases a reference book can come in handy. Easy to pick up without the need for extra screens (They are full with applications anyway)

This book is one of them, if you develop using jQuery this book has lots of short code snippets that will come in handy when developing using JQuery and Javascript.

 

 

 

The book has the basics of setting up the JQuery framework and start using it to creating Dom nodes, setting css styles,classes. Adding animations to elements and also a little section on how to use JQuery mobile.

And the great part is that the book has quick explanations and then a code snippet that you can test, So you will get a great reference guide and also learn to use jQuery more when you develop new applications.

The books developer audience is developers that isn’t experienced JQuery Developers but what to get started or just started to use JQuery.

Get your own copy here or from amazon

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