Html->url($url); $att = " "; if (is_array($options)){ foreach($options as $k=>$v){ $att.=$k.'="'.$v.'" '; } } echo "$text"; echo $this->_jsBlock("\$(\"#$aId\").click( function(){ \$.post(\"$url\", function(data){ \$(\"$target\").html(data); }); return false; }); "); } function observeField($element, $options){ $event = $options["event"]; $update = $options["update"]; $url = $this->Html->url($options["url"]); $code = $options["loading"].' $.ajax({ type: "POST", url: "'.$url.'", data: $("'.$element.'").serialize(), success: function(data){ $("'.$update.'").html(data); '.$options["complete"].' } }); '; return $this->_jsBlock($this->_addReady("\$(\"$element\").$event(function(){ $code })")); } function observeForm($element, $options){ $event = $options["event"]; $update = $options["update"]; $url = $this->Html->url($options["url"]); $code = '$("'.$element.'").ajaxSubmit({ target: \''.$update.'\', beforeSubmit: function(){'.$options["loading"].'}, success: function(){'.$options["complete"].'} } );'; return $this->_jsBlock($this->_addReady("\$(\"$element\").$event(function(){ $code return false; })")); } function _jsBlock($content){ return ""; } function _addReady($content){ return "\$(function(){ $content } );"; } function test(){ echo $this->_jsBlock($this->_addReady("alert(\"Jax Helper has been installed and ready to use!\");")); } } ?>