XUpload - Integration with jQuery framework

Message
Author
philwareham
Posts: 9
Joined: Jun 05, 2007 5:34 pm

Integration with jQuery framework

#1 Postby philwareham » Nov 17, 2008 10:21 am

Hi there,

I have a working installation of XUpload, but I want to incorporate the jQuery javascript framework on my page. However there is a conflict with the xupload.js, I think it is because I use the following jQuery recommended method to activate jQuery elements...

$(document).ready(function(){ *my jquery code here* }

Is there a way of modifying the xupload.js file so they play nice together?

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#2 Postby PilgrimX182 » Nov 17, 2008 10:31 am

Try to comment $ function in xupload.js

philwareham
Posts: 9
Joined: Jun 05, 2007 5:34 pm

#3 Postby philwareham » Nov 17, 2008 10:59 am

If I comment out...

Code: Select all

function $(elem){return document.getElementById(elem);}
At the start of the xupload.js, then my jQuery scripts all start to work as expected and the files upload to my server OK, but the upload progress box does not refresh/update at all.

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#4 Postby PilgrimX182 » Nov 17, 2008 12:11 pm

Check for JS errors. PM me your URL if possible.

philwareham
Posts: 9
Joined: Jun 05, 2007 5:34 pm

Solved!

#5 Postby philwareham » Nov 17, 2008 1:59 pm

OK, PilgrimX182 found a solution for this conflict as follows...

In the xupload.js file rename function (1st line) to:

Code: Select all

function $gget(elem){return document.getElementById(elem);}
Then automatically replace all $ in xupload.js with $gget and it will be all right.

Buyaphoto
Posts: 7
Joined: Jul 01, 2008 3:58 am

same problem with mootools

#6 Postby Buyaphoto » Feb 16, 2009 4:33 pm

has anyone had any luck integrating with mootools?

Ugly Mau
Posts: 12
Joined: Aug 30, 2007 9:15 am

#7 Postby Ugly Mau » May 05, 2009 10:53 am

Hello,
The solution proposed by philwareham is correct?
We can use it as "official"?

Thanks

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#8 Postby PilgrimX182 » May 05, 2009 1:08 pm

This is a 'hack', but it will work for you.

Ugly Mau
Posts: 12
Joined: Aug 30, 2007 9:15 am

#9 Postby Ugly Mau » May 05, 2009 2:29 pm

Ok, just to understand if this change causing other problems ...

I have the version 2.6 pro, in the version 3.0 this conflict is resolved?

wfrohwein
Posts: 1
Joined: Nov 07, 2009 9:19 am

Re: Solved!

#10 Postby wfrohwein » Nov 07, 2009 9:25 am

philwareham wrote:OK, PilgrimX182 found a solution for this conflict as follows...

In the xupload.js file rename function (1st line) to:

Code: Select all

function $gget(elem){return document.getElementById(elem);}
Then automatically replace all $ in xupload.js with $gget and it will be all right.
i got the new xupload pro version and i was trying to integrate with drupal which uses jquery. I renamed the xupload.js $ function to $$. I also had to modify upload.cgi. Instead of naming my function $gget like PilgrimX182 mentioned, i named it $$. So my upload.cgi looks like so:

Code: Select all

if($ENV{QUERY_STRING} =~ /^settings/)
{
   $c->{pass_required} = $c->{upload_password}&&1;
   print"Content-type: text/html\n\n";
   print"$_='$c->{$_}';" for qw(ext_allowed ext_not_allowed max_upload_files max_upload_size enable_file_descr pass_required email_required);
   print qq[if(\$\$('x_max_files'))\$\$('x_max_files').innerHTML = '$c->{max_upload_files}';];
   print qq[if(\$\$('x_max_size'))\$\$('x_max_size').innerHTML='$c->{max_upload_size}';];
   print q[if($$('x_password')){$$('x_password').style.display='block';}] if $c->{pass_required};
   print q[if($$('x_folder')){$$('x_folder').style.display='block';}] if $c->{allow_ext_folder};
   exit;
}
hope that helps anyone that is having the trouble i did

INTERNOZEROUNO
Posts: 8
Joined: Mar 23, 2011 7:20 pm

Re: Solved!

#11 Postby INTERNOZEROUNO » May 04, 2011 9:21 am

wfrohwein wrote:I renamed the xupload.js $ function to $$. I also had to modify upload.cgi.
Thank you! That works great!

ssanders
Posts: 6
Joined: Mar 06, 2012 4:29 pm

Fix the source?

#12 Postby ssanders » Mar 06, 2012 9:15 pm

While I adore open source so I can fix things myself...

jQuery is mad popular -- why not replace all the $() to $$() in an official release, especially for us who purchased Pro?