[jQuery] Targetting .class-0 .class-1 .class-2 .class-3
This is a beginner question. Does anyone know how to target $('.jquery-calendar-0') $('.jquery-calendar-1') $('.jquery-calendar-2') $('.jquery-calendar-3') etc... I need to run the following, where X is the number, but I don't know how many X exist until after the page renders. $('.jquery-calendar-X').calendar( {stuff} ) I can't find the solution in Learning Jquery (Chaffer and Swedberg), at least not in Chapter 2 How to Get Anything You Want. ;-) Thanks!
[jQuery] Re: Targetting .class-0 .class-1 .class-2 .class-3
Yes, perfect! Thanks! On Dec 3, 6:00 pm, Jeffrey Kretz [EMAIL PROTECTED] wrote: I would recommend your elements having two classes. One which stays the same, and the second one which changes. e.g. div class=jcalendar calendar0/div div class=jcalendar calendar1/div div class=jcalendar calendar2/div div class=jcalendar calendar3/div Then you could grab it with $('div.jcalendar'); JK -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of light-blue Sent: Wednesday, December 03, 2008 5:40 PM To: jQuery (English) Subject: [jQuery] Targetting .class-0 .class-1 .class-2 .class-3 This is a beginner question. Does anyone know how to target $('.jquery-calendar-0') $('.jquery-calendar-1') $('.jquery-calendar-2') $('.jquery-calendar-3') etc... I need to run the following, where X is the number, but I don't know how many X exist until after the page renders. $('.jquery-calendar-X').calendar( {stuff} ) I can't find the solution in Learning Jquery (Chaffer and Swedberg), at least not in Chapter 2 How to Get Anything You Want. ;-) Thanks!
[jQuery] if ($(event.target).is('a.edit')) with img
Hopefully simple problem. I click an img link, html like this a class=edit-building href=/edit-building/145 img src=icons/edit.png/ /a jquery like this if ($(event.target).is('a.edit-building')) { var building = function (data) { ..do stuff } $.get(event.target, null, building); return false; } but the binding doesn't work, probably because the target is my img not my link. How can I click the image and fire the code for my a.edit- building? Thanks!
[jQuery] Re: if ($(event.target).is('a.edit')) with img
Hi Leonardo, I was thinking about that too, but I need to rebind that event handler after an Ajax call. The following works, but seems ugly. Any pointers? $(document).ready(function() { function bindBuilding() { $('a.edit-building').click(function(){ var building = function (data) { //do stuff } $.get(this, null, building); return false; }); } bindBuilding(); function doAjaxStuff() { //perform ajax stuff bindBuilding(); } }); On Oct 2, 11:03 am, Leonardo K [EMAIL PROTECTED] wrote: Why don't use the simple click function? $('a.edit-building').click(function(){ //do stuff return false; }); On Thu, Oct 2, 2008 at 14:43, light-blue [EMAIL PROTECTED] wrote: Hopefully simple problem. I click an img link, html like this a class=edit-building href=/edit-building/145 img src=icons/edit.png/ /a jquery like this if ($(event.target).is('a.edit-building')) { var building = function (data) { ..do stuff } $.get(event.target, null, building); return false; } but the binding doesn't work, probably because the target is my img not my link. How can I click the image and fire the code for my a.edit- building? Thanks!
[jQuery] using click() with $(event.target).is(something)
I'm a Jquery newbie, so if this answer is available somewhere, please let me know. My user needs to click button B, which processes some info with AJAX (working great), and then needs to programmatically click button A, which itself runs an AJAX request. Button B works fine, but when it tries $('a.buttonA').click() the code in button A doesn't run. I suspect this is because I'm using $(event.target).is('a.buttonB'), resulting in no binding for click() to run. Can anyone confirm? Any suggestions to fix this? Thanks!
[jQuery] Re: using click() with $(event.target).is(something)
I think Andy might be correct about the binding issue. Since I'm relatively new to jquery, I'm likely missing something basic. Below is code sample... // $Id$ // Global killswitch if (Drupal.jsEnabled) { $(document).ready(function(){ $('body').click(function(event) { if ($(event.target).is('a.targetme')) { var listUnits = function (data) { var result = Drupal.parseJson(data); $('div.units').html(result['units']); $('div.units').css('display','inline'); $('div.units').fadeIn('slow'); } $.get(event.target, null, listUnits); return false; } if ($(event.target).is('a.unit')) { unitsLink=($(event.target).attr('href')); //global listRes = function (data) { var result = Drupal.parseJson(data); $('div.unitres').html(result['unitres']); $('div.unitres').css('display','inline'); $('div.unitres').fadeIn('slow'); } $.get(event.target, null, listRes); event.preventDefault(); //return false; } if ($(event.target).is('a.rescck-link')) { var listUnitRes = function (data) { var result = Drupal.parseJson(data); $('div.rescck').html(result['rescck']) .fadeIn('fast',function() { $.getScript('/misc/progress.js'); $.getScript('/misc/collapse.js'); $.getScript('/misc/autocomplete.js'); }).fadeIn('fast',function() { Drupal.behaviors.ajaxSubmit(); }).fadeIn('fast',function() { $('[EMAIL PROTECTED]' + unitsLink + ']').click(); }); $.ajax({ type: GET, url: unitsLink, dataType: script, success: function () {alert('great')} }); } $.get(event.target, null, listUnitRes); return false; } }); }); }
[jQuery] What does 'return false' do?
What does 'return false' do? I make an AJAX request from an HREF, which works. But the resulting page needs Javascript to run on it. I think 'return false' is preventing it. How do I fix that? Here's what I've read so far from the Chaffer / Swedberg book: If we wish to halt both, we can return false from our event handler, which is a shortcut for calling both. stopPropagation () and .preventDefault () on the event.
[jQuery] Simple Q: Javascript fails on JSON data
This is simple, but I'm lost. I click a link, and jquery loads a form using jquery and JSON (works great!) But, the form has collapsible fieldsets (using Drupal's collapse.js) and the javascript doesn't run on them. That's probably because the collapse.js needs to run on the newly loaded form elements but it *won't* because I'm doing 'return false' after my .get(). Workaround: If I intercept the form SUBMIT click and paste the collapse.js, then the javascript starts working on my form. That's not elegant. How do I properly adjust for this? Thanks!