You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by John Eichelsdorfer <je...@yahoo.com> on 2009/07/08 20:50:12 UTC
Using jQuery with Velocity
In attempting to integrate the JQuery UI datepicker tool into our site
http://jobbank.com/ http://jobbank.com/ , we are having an issue where the
jQuery code is being removed due to both projects using the "$" symbol.
jQuery has this link:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
http://docs.jquery.com/Using_jQuery_with_Other_Libraries that describes how
to modify the use of jQuery to attempt to get things working, but do you
have a preferred solution? Examples would be great if you have them.
Thank!
John
-----
John Eichelsdorfer
http://jobbank.com/ jobbank.com
--
View this message in context: http://www.nabble.com/Using-jQuery-with-Velocity-tp24397241p24397241.html
Sent from the Velocity - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by Byron Foster <by...@base2.cc>.
On Jul 13, 2009, at 7:22 , ChadDavis wrote:
>> Yes, this is a bug. In my test the following:
>>
>> $.x
>>
>> renders as:
>>
>> .x
>>
>
> Looks like the bug is in the parsing of a reference before the dot
> syntax, it allows an empty reference.
I created a bug for it here:
https://issues.apache.org/jira/browse/VELOCITY-729
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by ChadDavis <ch...@gmail.com>.
> Yes, this is a bug. In my test the following:
>
> $.x
>
> renders as:
>
> .x
>
Looks like the bug is in the parsing of a reference before the dot
syntax, it allows an empty reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by Byron Foster <by...@base2.cc>.
On Jul 13, 2009, at 5:57 , ChadDavis wrote:
>> Without it, the following code was trying to have "datepicker"
>> turned into a
>> velocity variable. Not sure if it should have, but...
>> $.datepicker.setDefaults({
>> dateFormat: 'mm/dd/yy',
>> showOn: 'focus',
>> changeMonth: true,
>> changeYear: true
>> });
>
> I'd like to understand why this is interpreted as a Velocity reference
> though. "." is not a legal reference name character. Is this a bug?
Yes, this is a bug. In my test the following:
$.x
renders as:
.x
So it simply eats the dollar sign, which isn't correct. But the
following:
$..x
$("foo")
renders correctly as:
$..x
$("foo")
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by ChadDavis <ch...@gmail.com>.
> Without it, the following code was trying to have "datepicker" turned into a
> velocity variable. Not sure if it should have, but...
> $.datepicker.setDefaults({
> dateFormat: 'mm/dd/yy',
> showOn: 'focus',
> changeMonth: true,
> changeYear: true
> });
I'd like to understand why this is interpreted as a Velocity reference
though. "." is not a legal reference name character. Is this a bug?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by John Eichelsdorfer <je...@yahoo.com>.
Wanted to thank you for the responses. Wanted to make the thing work before
responding. Ended up using the recommended ${esc.d}.
Without it, the following code was trying to have "datepicker" turned into a
velocity variable. Not sure if it should have, but...
$.datepicker.setDefaults({
dateFormat: 'mm/dd/yy',
showOn: 'focus',
changeMonth: true,
changeYear: true
});
-----
John Eichelsdorfer
http://jobbank.com/ jobbank.com
--
View this message in context: http://www.nabble.com/Using-jQuery-with-Velocity-tp24397241p24454038.html
Sent from the Velocity - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by ChadDavis <ch...@gmail.com>.
I use jquery with velocity all the time and I never noticed an issue.
For instance, the on ready handler and the selector patterns both work
fine for me. If velocity doesn't recognize a variable name after the
$, it just print's it straight through, right? Are you concerned
about a coincidental match . . . seems unlikely since the jqueyr $ is
always followed by a left parens; not even sure if that could be the
start of a valid reference name.
Am I missing something?
On Wed, Jul 8, 2009 at 12:50 PM, John Eichelsdorfer<je...@yahoo.com> wrote:
>
> In attempting to integrate the JQuery UI datepicker tool into our site
> http://jobbank.com/ http://jobbank.com/ , we are having an issue where the
> jQuery code is being removed due to both projects using the "$" symbol.
>
> jQuery has this link:
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries that describes how
> to modify the use of jQuery to attempt to get things working, but do you
> have a preferred solution? Examples would be great if you have them.
>
> Thank!
>
> John
>
>
> -----
> John Eichelsdorfer
>
> http://jobbank.com/ jobbank.com
> --
> View this message in context: http://www.nabble.com/Using-jQuery-with-Velocity-tp24397241p24397241.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Using jQuery with Velocity
Posted by Jason Tesser <ja...@gmail.com>.
Yes
I would use velocities escape tool to spit our the $ in your JS.
http://dotcms.org/community/documentation/documentation_repository/velocity/velocity-tools-1.2-doc/generic/EscapeTool.html#getD%28%29
so in other words $JQueryStuff you would write the velocity
${esc.d}JQueryStuff
enjoy :-)
Thanks,
Jason Tesser
dotCMS Lead Development Manager
1-305-858-1422
On Wed, Jul 8, 2009 at 2:50 PM, John Eichelsdorfer <je...@yahoo.com>wrote:
>
> In attempting to integrate the JQuery UI datepicker tool into our site
> http://jobbank.com/ http://jobbank.com/ , we are having an issue where the
> jQuery code is being removed due to both projects using the "$" symbol.
>
> jQuery has this link:
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries that describes
> how
> to modify the use of jQuery to attempt to get things working, but do you
> have a preferred solution? Examples would be great if you have them.
>
> Thank!
>
> John
>
>
> -----
> John Eichelsdorfer
>
> http://jobbank.com/ jobbank.com
> --
> View this message in context:
> http://www.nabble.com/Using-jQuery-with-Velocity-tp24397241p24397241.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
Re: Using jQuery with Velocity
Posted by bluejoe <bl...@gmail.com>.
Hi, John. I use velocity with jQuery, and find they work well. I think all you should pay attention to is esaping character '$'.
Ususally, I define a tool in tools.xml:
<data type="string" key="dollar">$</data>
<data type="string" key="D">$</data>
and use $D when I want to write jQuery codes such as: $('#QueryForm')
-bluejoe
----- Original Message -----
From: "John Eichelsdorfer" <je...@yahoo.com>
To: <us...@velocity.apache.org>
Sent: Thursday, July 09, 2009 2:50 AM
Subject: Using jQuery with Velocity
>
> In attempting to integrate the JQuery UI datepicker tool into our site
> http://jobbank.com/ http://jobbank.com/ , we are having an issue where the
> jQuery code is being removed due to both projects using the "$" symbol.
>
> jQuery has this link:
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries that describes how
> to modify the use of jQuery to attempt to get things working, but do you
> have a preferred solution? Examples would be great if you have them.
>
> Thank!
>
> John
>
>
> -----
> John Eichelsdorfer
>
> http://jobbank.com/ jobbank.com
> --
> View this message in context: http://www.nabble.com/Using-jQuery-with-Velocity-tp24397241p24397241.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
Re: Using jQuery with Velocity
Posted by Nathan Bubna <nb...@gmail.com>.
If your Velocity template has jQuery javascript (or any other lib that
offers the $ symbol as a shortcut), then i would recommend just not
using the shortcut symbol. Just use the jQuery variable. Or if you
really don't want to type six letters, then do:
var J = jQuery;
and use J instead of $. When two syntaxes are close like that, i would
argue that the more maintainable, readable solution is to avoid mixing
them, wherever possible. But if you really must mix them, then yes,
use the EscapeTool ($esc) or just do:
context.put("D", "$");
and use ${D} instead of ${esc.d}.
But do try to avoid mixing similar syntaxes when an easy alternative
is available.
On Wed, Jul 8, 2009 at 11:50 AM, John Eichelsdorfer<je...@yahoo.com> wrote:
>
> In attempting to integrate the JQuery UI datepicker tool into our site
> http://jobbank.com/ http://jobbank.com/ , we are having an issue where the
> jQuery code is being removed due to both projects using the "$" symbol.
>
> jQuery has this link:
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries
> http://docs.jquery.com/Using_jQuery_with_Other_Libraries that describes how
> to modify the use of jQuery to attempt to get things working, but do you
> have a preferred solution? Examples would be great if you have them.
>
> Thank!
>
> John
>
>
> -----
> John Eichelsdorfer
>
> http://jobbank.com/ jobbank.com
> --
> View this message in context: http://www.nabble.com/Using-jQuery-with-Velocity-tp24397241p24397241.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org