34 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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.

626 posts
  • Has referred more than 5000 members
  • Has sold $2M+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured in a magazine
+9 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
  • Has been part of the Envato Community for over 6 years
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
ChordsofLife says

I love you.

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

352 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 50+ members
  • Has sold $10,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+6 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;.

626 posts
  • Has referred more than 5000 members
  • Has sold $2M+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured in a magazine
+9 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
  • Has been part of the Envato Community for over 6 years
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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!

626 posts
  • Has referred more than 5000 members
  • Has sold $2M+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured in a magazine
+9 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
  • Has been part of the Envato Community for over 6 years
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 6 years
  • Has sold $100+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
ChordsofLife says

...that was so easy.

626 posts
  • Has referred more than 5000 members
  • Has sold $2M+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured in a magazine
+9 more
Kriesi says

;)

by
by
by
by
by
by