JSON.parseでハマった件

ハマったって程の事も無いけれど。
テンプレートから構造化したオブジェクトをJSに渡したい時は、下記みたいにするんですが

    var items = JSON.parse('[% items %]');

クオートを間違えるとエラーです

    var items = JSON.parse("[% items %]");

当然ですね!

jQueryのchildren関数の不思議

なぜかchildrenの帰り値はjQueryオブジェクトじゃない

$(".bonus_type").change(function(){
        var $selected_option = $(this).children('option:selected')[0];
        var selected_index = $selected_option.value;
        // NG 
        //var selected_index = $selected_option.val();
    });