Posted by Anonymous on January 30, 2012 at 11:12am
Start:
2012-02-06 19:00 Europe/London Event type:
User group meeting
On 1st Monday of the month we hold a session talk at http://theskiff.org and this month it's the turn of Craig Moore who is going to be giving us a little introduction to jQuery and Drupal.
Building on the session Craig gave at the recent Drupal ScienceCamp in Cambridge, Craig will be showing us the power of jQuery and how Drupal behaviours help us connect Drupal easily with jQuery plugins.
This is a free event, 7-9pm at Brighton's coolest coworking space http://theskiff.org, then we'll be off to the pub for a pint and more Drupal chats after.
Please do signup here so we get an idea of attendance!
Comments
Reminder - Drupal Brighton tonight - jQuery & Drupal with Craig
Just a quick reminder it's Drupal time tonight - 11 people registered so far so should be good!
Craig, thanks again for great
Craig, thanks again for a great talk - I found it very useful.
If you remember, I raised a point about certain jQuery functions seemingly not working in Drupal. I've dug out the original problem that alerted me to this as promised... (lucky you!)
The following is added via the theme but doesn't seem to work at all:
jQuery('<a href="/relationships/1">friends</a>').replaceWith('<p>Please f*cking work!</p>');The same js file contains functions that do work so it's not how I'm including js via the theme. I've seen issues on D.O about .replaceWith not working in Drupal 5, but my example is from a Drupal 7 site.
Anybody else experienced this?
According to the
According to the documentation on JQuery replacewith http://api.jquery.com/replaceWith/ , it takes a collection of elements (a jquery collection) and replaces them with the elements thst you specify. So according to your example,
jQuery('<a href="/relationships/1">friends</a>')Actually won't select any code, as you are creating an anchor tag with the href as /relationships/1. You need to confirm that your selection actually does something, the simplest way is to console.log it and check which elements in the page are to be replaced, so
console.log(jQuery('a'))should show a link to all of the anchor tags, which would then bejQuery('a').replaceWith('<p>Please f*cking work!</p>');with subfilters as you need (see http://jqfundamentals.com Selecting Elements for further details).I'd also question why you are using the jQuery handle and not $...
Cheers for that - I'll take
Cheers for that - I'll take another look.
I'm using the jQuery handle because I wrote that code waaaay back when I didn't even know I could use $ :)
Cracked it :)
Cracked it :) Thanks for your help. Lots to learn...
30 days to learn jQuery
BTW, if anyone else is interested in learning the ropes with jQuery, I've been doing this free online video course recently and have found it very helpful:
http://tutsplus.com/course/30-days-to-learn-jquery/
And of course
And of course http://jqfundamentals.com/