Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

Jquery in Joomla Install

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
flynny
Asked:
flynny
  • 6
  • 5
1 Solution
 
Pierre CorneliusCommented:
Try adding this to your click function:
event.preventDefault();
0
 
flynnyAuthor Commented:
where abouts please? I have tried adding this to the end of the click function  but it has not worked?
0
 
Pierre CorneliusCommented:
$('#profile-slide').click(function(e){
            $("#floating-profile").animate({left: parseInt((state % 2 - 1) * (332)) + 'px'}, "slow");
                e.preventDefault();
    state++;
  });
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
flynnyAuthor Commented:
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
 
Pierre CorneliusCommented:
having a look now...
0
 
flynnyAuthor Commented:
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
 
Pierre CorneliusCommented:
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
 
Pierre CorneliusCommented:
I see you updated and it is working now :)

I tested using:
Firefox 23
Chrome 28
IE 10

works in all 3
0
 
flynnyAuthor Commented:
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
 
flynnyAuthor Commented:
Excellant response and coding.
0
 
Pierre CorneliusCommented:
Glad to help. Good luck.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now