ber
ber

Reputation: 3

Double click needed in firefox (JQUERY)

I was advised to used this because i was having a problem, a link worked in FireFox ONLY when clicked the second time. This is to display an external html in a div called leftColumn.

$(function(){
  $('#ulWithAllTheLinks').delegate('li a', 'click', function(e){
     e.preventDefault;
     $('#leftColumn').load(this.href);
  });
});

My question is, that this displays the html with the content in a NEW page, I know that it has something to do with this:

<ul id="one">
  <li><a href="content.html">First Link</a></li>
</ul>

yet i don't know how to link this to the function

Upvotes: 0

Views: 777

Answers (1)

Nick Craver
Nick Craver

Reputation: 630449

event.preventDefault() is a function, so you need parenthesis on the end, like this:

$(function(){
  $('#ulWithAllTheLinks').delegate('li a', 'click', function(e){
     e.preventDefault();
     $('#leftColumn').load(this.href);
  });
});

Without the .preventDefault() (or return false;) working correctly, the default behavior will occur...going to that page.

Upvotes: 2

Related Questions