Tuesday, October 26, 2010

Re: Using js helper to call fancybox()

Ok, got it.

Not entirely sure why (I'm still pretty new with jQuery) but this is
what I found.

At first I was using this and could only get the pop-up box to show up
after the first click:

$elementid = 'add-report-' . $school['School']['id'];
$this->Js->get('#' . $elementid);
$this->Js->event('click', "$(\"#" . $elementid . "\")" .
'.fancybox();', array('stop' => true));

This is what ended up working correctly:
$this->Js->event('click', "$.fancybox({'href': this.href,});",
array('stop' => true));


On Oct 26, 11:02 am, Anthony <anthony.c.fra...@gmail.com> wrote:
> So I had originally set this up using the common.js and found that
> after the element in my view was updated the js bindings no longer
> worked.
>
> So I started looking into the JS helper to setup the link in my
> element.  Easy enough its now working, except it only seems to work on
> or after the second click.  The first click simply does nothing
> however if I put a break in (firebug) and click the link the execution
> stops on the correct line.
>
> It seems so easy what can I be missing?  All the links I created are
> working this way.  If I go down the list and click them one at a time
> nothing happens with any of them, but the second I click on one of
> them for a second time my .fancybox() is called.
>
> During the course of writing this I've found that its more related to
> fancybox.  If I replace the code with a simple alert it works as
> expected.  But since I typed all this out I'm going to submit it in
> hopes of someone else running across this and can help me out.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: