Re: [jQuery] Re: Functions

2009-11-19 Thread Vincent Robert
What you are looking for is event delegation. In your last version, you are attaching a click event handler to every a you add to your table. It can be time and resource consuming. A better way is to bind the click event to the container where you will load your dynamic content and wait for the

Re: [jQuery] Re: Functions

2009-11-18 Thread Denis Caggiano
Hi Greg, I'm defined an ID to my table (ID = tb) that have my report, and trying to code like this: $(#tb a).click(function() { alert('Test'); }); But it doesnt working. In other words, how can I define that all a in my table triggers an event when clicked? Tks

[jQuery] Re: Functions

2009-11-18 Thread Scott Sauyet
On Nov 18, 7:25 am, Denis Caggiano denisribe...@gmail.com wrote: I'm defined an ID to my table (ID = tb) that have my report, and trying to code like this:     $(#tb a).click(function() {         alert('Test');     }); #tb a points to link elements that are the direct children of the

Re: [jQuery] Re: Functions

2009-11-18 Thread Denis Caggiano
The hint of the day: *The other thing to make sure you're doing is to call your code once* *the DOM is loaded* *---By Scott* ** Im using AJAX and defyning the $(#tb a).click before the DOM is loaded and that was the problem. Here is my $.post now: $.post( 'adm_cobranca_ajax.asp', { mes:

Re: [jQuery] Re: Functions

2009-11-18 Thread Wil Everts
Have you tried simply doing: $(#tb a).click(function() { alert('Test'); }); Depending on the table's code will break your heart... Wil On Wed, Nov 18, 2009 at 4:25 AM, Denis Caggiano denisribe...@gmail.comwrote: Hi Greg, I'm defined an ID to my table (ID = tb) that have my report,

Re: [jQuery] Re: Functions

2009-11-18 Thread Denis Caggiano
Now Im get confused... Wil, Is the code that you suggested equal that I wrote? Mine $(#tb a).click(function() { alert(this.id); }); Wil $(#tb a).click(function() { alert('Test'); }); Tks

[jQuery] Re: Functions

2009-11-17 Thread Greg Tarnoff
You are kind of defeating the purpose of Jquery if you put the call to the function in an A element. Does the parent of the A element in question have an ID? You could then call $('parent a'). If there is more than one A in there you can target it with other selectors

[jQuery] Re: Functions

2009-06-09 Thread MorningZ
function thisismyfunction(){ } $(document).ready(function(){ code in here }); $(document).ready(function(){ thisismyfunction() }); On Jun 9, 6:40 am, simon si...@uvfx.tv wrote: I have some code seperated by  script: $(document).ready(function(){   code in here  

[jQuery] Re: Functions

2009-06-09 Thread simon
so I would put my function outside of the $(document).ready(function() { }? Many thanks Si

[jQuery] Re: Functions

2009-06-09 Thread MorningZ
yes On Jun 9, 9:20 am, simon si...@uvfx.tv wrote: so I would put my function outside of the $(document).ready(function() { }? Many thanks Si

[jQuery] Re: Functions

2009-06-09 Thread simon
thanks for that, the only thing i did not try, I am learning now :-) many thanks Si

[jQuery] Re: Functions and variables

2008-12-09 Thread Will
Thanks. I ready an article somewhere and it mentioned not combining old coding forms with new in reference to jQuery. It didn't make much sense to me and this confirms it. I'll continue to code with functions and such and just supplement with jQuery where beneficial. Thanks On Dec 4, 6:36 

[jQuery] Re: Functions and variables

2008-12-09 Thread brian
On Tue, Dec 9, 2008 at 10:12 AM, Will [EMAIL PROTECTED] wrote: Thanks. I ready an article somewhere and it mentioned not combining old coding forms with new in reference to jQuery. It didn't make much sense to me and this confirms it. I'll continue to code with functions and such and just

[jQuery] Re: Functions and variables

2008-12-04 Thread Max
Sorry...this question is a little ambiguous to me. Can you be more specific or give an example/use case? I think you will have to hard code every event, because otherwise there's no logic dictating what happens when, say, you click something. As for defining actual functions and reusable

[jQuery] Re: Functions and variables

2008-12-04 Thread Michael Geary
jQuery isn't a separate language with its own rules. It's still JavaScript code, just like any other JavaScript code. Functions, variables, reusable code, those are all good practice, and none of it changes because you're using jQuery. Could you give a specific example of some jQuery code that

[jQuery] Re: functions after $.get work strange

2007-09-28 Thread [EMAIL PROTECTED]
Erik Beeson wrote: The value from $.get CAN NOT be returned from isTracked because isTracked will have returned before the $.get callback executes. Shame :/ But thank you for that answer. I was fighting because I thought that it is possible. Waste of time :/ So I have no choice and put all

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Erik Beeson
$.get is asynchronous, meaning the call to $.get returns immediately, even before the callback has happened. To answer your specific question, setting a variable who's scope is outside the callback is as easy as defining the variable outside the callback: var foo; $.get(..., function() { foo =

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Guy Fraser
Erik Beeson wrote: $.get is asynchronous, meaning the call to $.get returns immediately, even before the callback has happened. To answer your specific question, setting a variable who's scope is outside the callback is as easy as defining the variable outside the callback: Erik - your

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
function isTracked(personcode, callback) { $.get('trackstudent/istracked.php', {'personcode': personcode}, callback); } isTracked(code, function(tracked) { // do something with tracked, exactly as you would have done above. }); I thought that I understand that but Im doing something

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
First of all - Thank You very much - it is good lesson. To answer your specific question, setting a variable who's scope is outside the callback is as easy as defining the variable outside the callback: var foo; $.get(..., function() { foo = ...; }); I tried that before: function test()

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Michael Geary
with Firebug enabled, and watch the console to see the order of execution. -Mike -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, September 27, 2007 7:01 AM To: jQuery (English) Subject: [jQuery] Re: functions

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
To answer your specific question, setting a variable who's scope is outside the callback is as easy as defining the variable outside the callback: var foo; $.get(..., function() { foo = ...; }); Ahh, I know know where was my mistake. I tried something like that: function a() { var ret;

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
Michael Geary wrote: You're still expecting things to happen in the wrong order. It's *inside the callback* that the data becomes available, and this is long after isTracked() returns. Try this instead: Yes, but I want have a function that will return what i get from istracked.php to use it

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Michael Geary
Michael Geary wrote: You're still expecting things to happen in the wrong order. It's *inside the callback* that the data becomes available, and this is long after isTracked() returns. From: [EMAIL PROTECTED] Yes, but I want have a function that will return what i get from

[jQuery] Re: functions not working on ajax generated content

2007-08-19 Thread Michael Geary
From: MrNase I have the function called init() where I use Ajax.get to fetch the list and I have several other functions but writing them down like: $(document).ready(function() { init(); otherfunction(); // booth need the data provided by init(); function(); });