34 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 100 and 1 000 dollars
  • United States
ChordsofLife says

I’m so confused :( I have data outputted from the database, looped with a for each loop. In each, I have a link to add a phone number to each entry. When I click the link, I want a one input box form to fade in underneath.

I have it all set up, but when I click the link, the form fades in while the page loads and then disappears. Helps? I can post some code if need be, please let me know.

615 posts
  • Power Elite Author
  • Referred more than 2000 users
  • Power Elite Author: Sold between 2 000 000 - 4 999 999 dollars
  • Austria
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
+4 more
Kriesi says

sounds like the default behaviour for the link is not deactivated. you can do this in 2 ways:

$( ‘a’ ).click( function (e){

e.preventDefault();

// do something

});

or

$( ‘a’ ).click( function (e){

// do something

return false;

});

34 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 100 and 1 000 dollars
  • United States
ChordsofLife says

I love you.

Would you mind explaining what the e in the function does? I used your second example.

352 posts
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 10 000 and 50 000 dollars
+1 more
danharper says

I’m not too familiar with jQuery, but it looks like it stops the browser from taking it’s default action when clicking a link (appending a # to the end of the URL )—the same as return false;.

615 posts
  • Power Elite Author
  • Referred more than 2000 users
  • Power Elite Author: Sold between 2 000 000 - 4 999 999 dollars
  • Austria
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
+4 more
Kriesi says

the e in the second function is only a copy/paste error and not necessary ;)

the e in the first function is the event object created by jQuery which is passed to the event handler. this object has various attributes and methods you can utilize, if you are interested you can read the documentation at

http://docs.jquery.com/Events/jQuery.Event

the method preventDefault(), as dan already stated, stops the default action for the browser. The default action for clicking a link is going to the link target.

34 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 100 and 1 000 dollars
  • United States
ChordsofLife says

One more question (I really appreciate the help!):

What do I have to do to have the code in the link location (delete.php) run without going to that page? It seems like my options are go to the page in which case the jquery doesn’t run, or run the jquery, in which case the entry doesn’t delete.

Thanks!

615 posts
  • Power Elite Author
  • Referred more than 2000 users
  • Power Elite Author: Sold between 2 000 000 - 4 999 999 dollars
  • Austria
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
+4 more
Kriesi says

In this case you would have to send an ajax request to the server. Something which isnt really hard with jquery. I would recommend checking out some tutorials on nettuts if you have never done this before ;)

34 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 100 and 1 000 dollars
  • United States
ChordsofLife says

I usually skim the JQuery ones, but I’ve never really needed to apply it, so I guess I didn’t get much out of it.

I’ll actually sit down a read one now though, since I can apply it. I’m going to start with whatever, but is there one you can recommend off the top of your head that has what I’m looking for?

Again, thanks!

34 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 100 and 1 000 dollars
  • United States
ChordsofLife says

...that was so easy.

615 posts
  • Power Elite Author
  • Referred more than 2000 users
  • Power Elite Author: Sold between 2 000 000 - 4 999 999 dollars
  • Austria
  • Bought between 100 and 499 items
  • Has been a member for 5-6 years
+4 more
Kriesi says

;)

by
by
by
by
by
by