Created
November 25, 2011 09:00
-
-
Save violetyk/1393085 to your computer and use it in GitHub Desktop.
[cakephp]jsヘルパー、関数をbufferしてgetしたjqueryオブジェクトにeventを結びつける
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 入力タイプの切替イベント。 | |
$func = ' | |
function changeType() { | |
var type = parseInt($("#SurveyQuestionType").val()); | |
if(type <= 3){ | |
$(".question_item").show("normal"); | |
} else { | |
$(".question_item").hide("fast"); | |
} | |
} | |
changeType(); | |
'; | |
// getしたjqueryオブジェクトをclickイベントに結びつける。 | |
$js->buffer($func); | |
$js->get("#SurveyQuestionType"); | |
$js->event("click", 'changeType();'); | |
// 質問の選択肢の追加イベント。 | |
$js->get("#btn_add_question_item"); | |
$callback = ' | |
$(".question_item:last").after($(".question_item:last").clone()); | |
'; | |
$js->event("click", $callback); | |
// バッファを出力。 | |
e($js->writeBuffer(array('inline' => true))); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment