Skip to content

Instantly share code, notes, and snippets.

@kblomqvist
Created July 5, 2011 19:41
Show Gist options
  • Save kblomqvist/1065701 to your computer and use it in GitHub Desktop.
Save kblomqvist/1065701 to your computer and use it in GitHub Desktop.
An idea of the new api for setting js into Zend_JQuery/Dojo onload script container
<?php
// Old way
// Set onload script
$this->jQuery()->onLoadCaptureStart(); ?>
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
<?php $this->jQuery()->onLoadCaptureEnd(); ?>
<?php
// New way to do it
// Set onload script
$this->jQuery()->onload = <<<JS
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
JS;
// Append onload script (with the short one)
$this->jQuery()->onload .= '$( "#datepicker" ).datepicker();'
// Clear onload script
$this->jQuery()->onload = '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment