Prev | Current Page 146 | Next

David Berube

"Practical Reporting with Ruby and Rails"

hide();
var player_id = $('player_id').value;
var game_id = $('game_id').value
if( player_id && game_id ) {
new Ajax.Updater("chart",
'/performance'+
'/' + $('game_id').value +
'/' + $('player_id').value,
{evalScripts:true,
method:'get',
onComplete:function(){
setTimeout("$('chart').show();",
400); }
}
);
}
}
Event.observe("player_id", "change", show_report);
Event.observe("game_id", "change", show_report);

This JavaScript code defines a new function, show_report, and then uses Prototype??™s
Event.observe function to run the show_report function whenever either of the drop-down
lists changes. The show_report button hides the existing chart, and then checks if both a
player and game were selected. If neither or just one of them was selected, then the routine
does nothing. If both are selected, then it uses Ajax.Updater to call the show method of
the Performance controller, passing it both the ID of the selected game and the ID of the
selected player. (Note that you don??™t need to specify explicitly that it??™s the show action,
because you defined an appropriate route in your routes.


Pages:
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
wciągarki linowe zasady pokera Poker Porady Everest Poker teksty piosenek