AJAX framework or native jquery?

2 replies [Last post]
dianikol
Offline
Last seen: 7 years 37 weeks ago
Joined: 2011-04-27

Hello to the forum!

So, I am a little confused about this topic. Drupal 7 provides a AJAX framework which in a nutshell is how to make AJAX requests without writing javascript. For example lets say i have a link somewhere in a block which loads the most recent articles. It's not a real problem but you get the idea. I normally would write the appropriate js file using jquery's AJAX methods and so on.

The question is why i should prefer the framework instead of native jquery and vise versa ... ? There aren't many tutorials about AJAX in drupal 7 out there...

What's your opinion?

Thank you

ajeancharles3
Offline
Last seen: 8 years 10 weeks ago
Joined: 2011-09-12
AJAX framework or native jquery?

Key concept: "Graceful degradation" if javascript is disabled the functionality will still work as long as you code it the right way using the framework.

If you use JQuery to code your functionality, you are on your own, if javascript does not work. your functionality does not exist at the server side level

Chris Shattuck
Offline
Last seen: 10 weeks 3 days ago
Joined: 2009-08-16
To add ajeancharles3's

To add ajeancharles3's answer, there are a few things you get from using Drupal for this instead of writing your own jQuery:

  • Often, the implementation is simpler (once you know what it is).
  • The jQuery can be modified by other modules through the use of alter hooks.

That said, there are still times where you'll end up writing your own jQuery / JavaScript, and that's totally fine. As long as it's in a standard place, using the standard enclosures (see 3:22 - How to use the dollar sign as an alias for the jQuery object), that should be enough to guide other developers to the right place to make their modifications.

Cheers,
Chris

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:


Loading...
Contact us

Below are the supported keyboard shortcuts for our video player.

space
Start / stop video
shift
Go to next video
shift
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
1...9
Jump to a percentage (2 is 20%, for example)
f
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
$29
1 month
$156
6 months
10% off
$276
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
user
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.