Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Jquery in Joomla Install

Posted on 2013-10-25
11
Medium Priority
?
288 Views
Last Modified: 2013-10-28
Hi all,

I have a module in a joomla installation which uses jquery.

Basically I have a link (with url='#') on one side of the page, when the user clicks this I use jquery to slide a div panel containing a form out.

However, when clicking it redirecting to the same url but with the # char appended?

Is this a setting I am missing? Has anyone else seen this?

	$('#profile-slide').click(function(){
		$("#floating-profile").animate({left: parseInt((state % 2 - 1) * (332)) + 'px'}, "slow");
    state++;
  });    

Open in new window


    	<div id="floating-profile">
           	<div class="tab"><a id="profile-slide" href="#"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/images/view-profile.png" alt="View my Profile"/></a></div>
            <div id="floating-content">
            	<jdoc:include type="modules" name="floating-profile"/>
        	</div>
    	</div>

Open in new window

0
Comment
Question by:flynny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39600713
Try adding this to your click function:
event.preventDefault();
0
 

Author Comment

by:flynny
ID: 39600726
where abouts please? I have tried adding this to the end of the click function  but it has not worked?
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39600762
$('#profile-slide').click(function(e){
            $("#floating-profile").animate({left: parseInt((state % 2 - 1) * (332)) + 'px'}, "slow");
                e.preventDefault();
    state++;
  });
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:flynny
ID: 39605195
Many thanks for this.

Ok it seems to be working fine on Chrome,

But in IE and Firefox, clicking to slide out works, but when the button is clicking to slide back in it is not working.

coudl this code cause this issue?

can be seen here, ive setup a default user;

www.asianrishta.co.uk
login: mflynn pass: mflynn

on the left hand side you can see the view profile button.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39605227
having a look now...
0
 

Author Comment

by:flynny
ID: 39605229
hi PierreC,

I have just debugged using jquery and seen that I was missing passing the 'e' event tot he function.

I have changed this re freflect the above, but unfortunately it now still seems to be redirecting?
0
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 2000 total points
ID: 39605242
refer to:
 $('#profile-slide').click(function(e){
$("#floating-profile").animate({left: parseInt((state % 2 - 1) * (332)) + 'px'}, "slow");
event.preventDefault();
state++;
}); 

Open in new window

you are passing it as "e", but referring to it as "event". So after the call to event.preventDefault() an error occurs and "state++" never gets called which is what is breaking your close/hide action as the formula you are using relies on the state var.
change event.preventDefault();
to e.preventDefault();


another thing, why use that formula and state var? why not just?
if ($("#floating-profile").position().left === 0) { $("#floating-profile").animate({left: "-=332px"}, "slow");}
else { $("#floating-profile").animate({left: "+=332px"}, "slow");}

Open in new window

0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39605263
I see you updated and it is working now :)

I tested using:
Firefox 23
Chrome 28
IE 10

works in all 3
0
 

Author Comment

by:flynny
ID: 39605283
Hi Pierre,

Many thanks for this.

Sorry I should have seen this error. Many thanks.

The slide back is automatically added in to but obviously as it was erroring on the event it was not hooking this up.

Thanks again.
0
 

Author Closing Comment

by:flynny
ID: 39605284
Excellant response and coding.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39605285
Glad to help. Good luck.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question