Permalink
Browse files

Fixed a bug where editing a player's chips would duplicate their upda…

…te link.
  • Loading branch information...
1 parent d96f64f commit 0fbb55f3cc8a3ebebb627c88a577e5807b997719 @JohnB committed Jan 26, 2012
Showing with 20 additions and 17 deletions.
  1. +20 −17 poker.js
View
@@ -54,24 +54,27 @@ var Poker = {
if( !isNaN(chip_value) ) {
var player = Poker.current_player;
var update_player = "update_"+player;
- var update_element = '<li id="contain_'+player+'" class="ui-btn ui-btn-icon-right ui-li-has-arrow '+
- 'ui-li ui-corner-top ui-corner-bottom ui-btn-up-e" data-theme="e" >'+
- ' <div class="ui-btn-inner ui-li ui-corner-top" aria-hidden="true">'+
- ' <div class="ui-btn-text">'+
- ' <a href="#chip_value_page" class="ui-link-inherit" id="'+update_player+'">'+
- ' '+player+"&nbsp;<span id='chips_for_"+player+"'></span>"+
- ' </a>'+
- ' </div>'+
- ' <span class="ui-icon ui-icon-arrow-r ui-icon-shadow"></span>'+
- ' </div>'+
- '</li>';
- $('#players_list').append(update_element);
- $('#'+update_player).click(function(event) { Poker.select_player(player); });
-
+ var update_content = player+"&nbsp;$"+chips;
+ var update_player_el = $('#'+update_player);
Poker.players[Poker.current_player] = chip_value;
-// $('#contain_'+Poker.current_player).show();
- $('#chips_for_'+Poker.current_player).html("$"+chips);
- $('#add_'+Poker.current_player).hide();
+ if(update_player_el.length > 0) {
+ update_player_el.html(update_content);
+ } else {
+ var update_element = '<li id="contain_'+player+'" class="ui-btn ui-btn-icon-right ui-li-has-arrow '+
+ 'ui-li ui-corner-top ui-corner-bottom ui-btn-up-e" data-theme="e" >'+
+ ' <div class="ui-btn-inner ui-li ui-corner-top" aria-hidden="true">'+
+ ' <div class="ui-btn-text">'+
+ ' <a href="#chip_value_page" class="ui-link-inherit" id="'+update_player+'">'+
+ ' '+update_content+
+ ' </a>'+
+ ' </div>'+
+ ' <span class="ui-icon ui-icon-arrow-r ui-icon-shadow"></span>'+
+ ' </div>'+
+ '</li>';
+ $('#players_list').append(update_element);
+ $('#'+update_player).click(function(event) { Poker.select_player(player); });
+ $('#add_'+Poker.current_player).hide();
+ }
}
},

0 comments on commit 0fbb55f

Please sign in to comment.