Using JQuery in .jelly file

1,029 views
Skip to first unread message

Adrien Lecharpentier

unread,
Jun 22, 2011, 11:31:00 AM6/22/11
to Jenkins Developers
Hi all,

I'd like to use some jQuery function in a .jelly page. The .js files are outside of jenkins, so I use:

  <script>
  $().ready(function() {
 $("#more").jTruncate({
  length: 10,
  minTrail: 0
 });
});
  </script>

before the <l:layout tag of my .jelly file. The fact is that in the output page, the scripts are in the <head> tag of the page but it seems there is a conflict with other .js of jenkins because the function I want to use doesn't work.

Is anyone who tried to use something like this? Have you any idea of how can I fix that?

Regards,
--
Adrien Lecharpentier

Richard Bywater

unread,
Jun 22, 2011, 3:16:45 PM6/22/11
to jenkin...@googlegroups.com
Try setting the jquery noconflict mode (don't have link handy but
google will be your friend hopefully)

On a side matter, does Jenkins have a "preferred" js library?
Personally Im not sure I like the idea of dragging in external js
outside of the Jenkins app (might just be me :) )

Richard.

On Thursday, June 23, 2011, Adrien Lecharpentier

Adrien Lecharpentier

unread,
Jun 23, 2011, 4:04:40 AM6/23/11
to jenkin...@googlegroups.com
Hi,

yes I tried the noConflict settings but it didn't fix my problem. Maybe I didn't set it right, but it was working in a html page outside of jenkins.

I'm just trying to use jQuery in the page, when I'm sure it is working, I will include the js page in my plugin, just to be sure to always have access to it..

Regards,

--
Adrien Lecharpentier


2011/6/22 Richard Bywater <rbyw...@gmail.com>

Sven Strittmatter

unread,
Jun 25, 2011, 5:28:25 AM6/25/11
to jenkin...@googlegroups.com
Hi,

Am 22.06.11 17:31, schrieb Adrien Lecharpentier:

> <script
> src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
> <script
> src="http://jtruncate.googlecode.com/svn/trunk/jquery.jtruncate.js"/>
> <script>
> $().ready(function() {
> $("#more").jTruncate({
> length: 10,
> minTrail: 0
> });
> });
> </script>

Try:

(function($) {
$(function() {


$("#more").jTruncate({
length: 10,
minTrail: 0
});
});

})(jQuery);

When you put the code in Firebug, what does it say?

My question (I asked myself a lot of time): Why is jQuery not the
default lib for Jenkins. I'm developing web-foo since 7 years now and in
my experience jQuery is THE ONLY ONE js-lib you want to use. All other
libs are (sorry for that hard word) bullshit.

--
"Ich habe vom Glauben zum Wissen konvertiert." (Abdel-Samad)

R. Tyler Croy

unread,
Jun 25, 2011, 10:04:14 PM6/25/11
to jenkin...@googlegroups.com

Bundling dependencies like jQuery with Jenkins provides a number of
difficulties in the version management of the new dependency.

What version do we bundle? How/when do we decide to upgrade, if we upgrade the
core jQuery to a more recent release, how will that break plugins? What should
the deprecation policy be?

Additionally, if you rely on externally hosted JavaScripts for your plugin,
you're more or less guaranteed to never work in a corporate environment.

IMHO it's far more trouble than it's worth, especially with a library like
jQuery which is fairly small and doesn't provide a lot of end-user
improvements.


I've been developing web-foo for just as long as you have, jQuery is certainly
not the only toolkit nor the central toolkit I see people using regularly.
There are a couple other major ones (e.g. Prototype) out there, and Jenkins
selecting one to bundle would be an impressive amount of bike-shedding with
almost zero practical benefits (again, IMHO).


Cheers
- R. Tyler Croy
--------------------------------------
Code: http://github.com/rtyler
Chatter: http://identi.ca/agentdero
http://twitter.com/agentdero

Kiyotaka Oku

unread,
Jun 26, 2011, 12:14:32 AM6/26/11
to jenkin...@googlegroups.com

Sven Strittmatter

unread,
Jun 27, 2011, 4:48:46 AM6/27/11
to jenkin...@googlegroups.com
Hi R. Tyler,

Am 26.06.11 04:04, schrieb R. Tyler Croy:

> Bundling dependencies like jQuery with Jenkins provides a number of
> difficulties in the version management of the new dependency.

Each third party lib brings this problem, isn't it? And Jenkins just
uses some third party libs, right?

> What version do we bundle? How/when do we decide to upgrade, if we upgrade the
> core jQuery to a more recent release, how will that break plugins? What should
> the deprecation policy be?

Yes, this questions need an answer. But you have to answer them on each
lib Jenkins uses, and there are some libs already included, right? So
that's IMO an absolute normal job for developers to give answers on such
questions :)

But I don't say that's easy.

> Additionally, if you rely on externally hosted JavaScripts for your plugin,
> you're more or less guaranteed to never work in a corporate environment.

I don't like including jQuery via google ajax API. I code a lot in the
train without internet :) And yes, corporate env. is also an issue. Not
good when Jenkins will not work, when the Google Ajax API is down for
any reason.

> IMHO it's far more trouble than it's worth, especially with a library like
> jQuery which is fairly small and doesn't provide a lot of end-user
> improvements.

I don't think so. There is already a JS lib included. I've seen some
posts here some time ago with a discussion to replace it. Because its
development was discontinued. And I totally disagree that jQuery does
not provide a lot of end-user improvements. It gives you standardized
way to manipulate DOM with CSS3 over all major browsers. And the code
quality of jQuery is very good. And yes, the lib is very small but
provides a powerful plugin architecture.

> I've been developing web-foo for just as long as you have, jQuery is certainly
> not the only toolkit nor the central toolkit I see people using regularly.

> There are a couple other major ones (e.g. Prototype) ...

*eeeeek* Sorry, but Protoype is out of scope. No one will use it by
choice. It is a bad designed lib: It changes the prototype of internal
JS classes (it's possible @see Douglas Crockford) and it "simulates" a
class like object systems which leads to misunderstanding of JavaScript.
Other libs? ExtJS? JavaScriptMVC? Bloated, same problem, old concepts.
IMO the future is jQuery and it's plugin concept.

cheers
-sven

Adrien Lecharpentier

unread,
Jun 27, 2011, 9:25:11 AM6/27/11
to jenkin...@googlegroups.com
thanks!! It works. 

I don't think putting any jquery lib in the core is a good idea as some company may refuse to use those libs..

--
Adrien Lecharpentier


2011/6/25 Sven Strittmatter <weltra...@googlemail.com>

Sven Strittmatter

unread,
Jun 28, 2011, 3:49:54 AM6/28/11
to jenkin...@googlegroups.com
Am 27.06.11 15:25, schrieb Adrien Lecharpentier:

> thanks!! It works.
>
> I don't think putting any jquery lib in the core is a good idea as some
> company may refuse to use those libs..

Ok, that could be an argument, but Jenkins is already using libs (see
dependencies in pom.xml) what about that? IMO refuses company NOT
jQuery, they refuse open source at all.

Anyway, the possibility to plug in jQuery with Kiyotakas plugin is a
good way. Everybody has the free choice to use it or not :)

-Sven

R. Tyler Croy

unread,
Jun 30, 2011, 1:24:07 PM6/30/11
to jenkin...@googlegroups.com

POM dependencies are a bit easier to manage because of Maven and the fact that
there is an actual /build/ happening. While we can't account for a regression
in a particular dependency's API, if that API is changed somehow, we can easily
find out via build errors.

My concern with JavaScript-based dependencies is that it's trickier to spot
issues before a user hits them while using Jenkins.

I am a fan of the jQuery plugin, I think if a lot of plugins started to depend
on it, *then* we would have a good compelling reason to pull that plugin into
the "base" Jenkins install.

Reply all
Reply to author
Forward
0 new messages