Issues

ZF-11048: View helper binds onload scripts to jQuery's ready event

Issue Type: Docs: Problem Created: 2011-02-08T01:57:23.000+0000 Last Updated: 2012-06-19T19:24:17.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

Reporter: Juha Suni (zuhac) Assignee: Frank Brückner (frosch) Tags: - ZendX_JQuery

  • FixForZF1.12

Related issues: Attachments: - ZendX_JQuery-View-JQuery.xml.patch

Description

Onload scripts registered using JQuery view helper are bound to jQuery's ready event, which is wrong. Even the documentation for ZendX jQuery component says that the view helper handles "$(document).onLoad() events", while it actually uses $(document).ready().

I think that the view helper should use $(window).load() instead of $(document).ready(). Using load event is safer solution, since at onload stage all document resources (including javascript files) are loaded, which is not necessary the case with the ready event.

This suggested solution is unfortunately not fully backwards compatible. See following example, which would be OK in current implementation (not tested): $this->jQuery()->addOnLoad('$(window).load(alert("Registered window onload callback"););');

Comments

Posted by Kim Blomqvist (kblomqvist) on 2011-04-23T09:18:49.000+0000

bq. Using load event is safer solution, since at onload stage all document resources (including javascript files) are loaded, which is not necessary the case with the ready event.

This is not quite true, see [http://api.jquery.com/ready/].

Posted by Kim Blomqvist (kblomqvist) on 2011-04-27T17:39:41.000+0000

Documentation should be clarified so that ready() event is used instead of onLoad(). I think it would be sufficient if

"Handling $(document).onLoad() events."

is replaced by

"Handling $(document).ready() events."

Posted by Frank Brückner (frosch) on 2012-04-27T08:19:32.000+0000

Patch added.

Posted by Rob Allen (rob) on 2012-06-19T19:24:17.000+0000

Fixed in 24980(trunk) and 24981(release-1.12)

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts