[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread Giant Jam Sandwich
Great to hear. Your gallery is shaping up nicely. Great job. I'm 99.9% sure that the w3c spec states that an ID cannot begin with a number. Brian On Apr 21, 9:21 am, wyo <[EMAIL PROTECTED]> wrote: > On 21 Apr., 15:12, Giant Jam Sandwich <[EMAIL PROTECTED]> wrote:> Try this > instead: > > >

[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread wyo
On 21 Apr., 15:12, Giant Jam Sandwich <[EMAIL PROTECTED]> wrote: > Try this instead: > > for (var i in folders) { > $('#f'+i).bind('click', function() { > alert ($(this).attr("id")); > }); > } > Perfect. Besides is it allowed to use just number as id's? O. Wy

[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread Giant Jam Sandwich
for (var i in folders) { var b = '#f'+i; alert (b); $(b).bind('click', function() { alert (b); }); } Try this instead: for (var i in folders) { $('#f'+i).bind('click', function() { alert ($(this).attr("id")); }

[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread wyo
On 21 Apr., 14:52, Giant Jam Sandwich <[EMAIL PROTECTED]> wrote: > Unless you need the unique ID for each paragraph, it might be easier > to bind the click by the class name. jQuery will perform the foreach > logic for you. > Well depending on which folder is clicked I'd like to switch to a certai

[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread wyo
> The javascript part looks alright to me. Is there any data in the > folders array on the client side when the script gets executed? Do you > have a sample page online? > Yes, http://www.orpatec.ch/index.php?page=gallery.php Is there a way to retrieve the id of the bound element? O. Wyss

[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread Giant Jam Sandwich
Hi wyo, Unless you need the unique ID for each paragraph, it might be easier to bind the click by the class name. jQuery will perform the foreach logic for you. ... your PHP code ... then in the head of your document ... $(function(){ // wait until the document is ready $(".folder").click(fu

[jQuery] Re: How to bind to dynamic elements

2007-04-21 Thread Roman Weich
wyo schrieb: I've a dynamically created array var folders = new Array(); folders = encode ($folders) ?>; and html created with foreach ($folders as $key => $d) { echo "$d"; } and would like to bind a click handler to each element like for (var i i