for(var i = 0; i < 30; i++) {
 jQuery('#day_' + i).click(function() {
   jQuery('#' + this.id+ '_modal').jqmShow();
 });
}

maybe it works this way

2007/12/22, Rabbit <[EMAIL PROTECTED]>:
>
>
> The following code:
>
> for(var i = 0; i < 30; i++) {
>   jQuery('#day_' + i).click(function() {
>     console.log('i is ' + i);
>     jQuery('#day_' + i + '_modal').jqmShow();
>   });
> }
>
> Runs, but always reports "i is 30".
>
> Now, I understand why it does that, but why doesn't the jqmShow method
> work? It appears as though the code that "gets executed" is dynamic.
> In other words, when the click event occurs JavaScript looks up the
> code as it was at the end of its execution, when variable i is 30,
> instead of "remembering" that at one point it was something else.
>
> Did that make sense?
>
> Any ideas how to get around this without typing in all 30 click events?
>

Reply via email to