I got around it by using some jQuery's each and selector methods.

jQuery('.calendar_cell_active').each(function() {
  $('#' + $(this).attr('id') + '_modal').jqm();

  $(this).click(function() {
    $('#' + $(this).attr('id') + '_modal').jqmShow();
  });
});

It's a little bit more confusing, but basically I've setup my HTML
such that each day's cell in the calendar has an ID of "day_x" and
that day's respective modal content is ID'd like "day_x_modal". This
allows me to "know" what calendar cell is attached to what modal
content.

Yay jQuery!

---

On Dec 22, 12:12 am, Rabbit <[EMAIL PROTECTED]> wrote:
> 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