Two buttons labeled Accept and Deny are present, each revealing a different div with an additional button.
Upon clicking the Accept button, it should disable the Deny button, slide in the Accept form, and allow the user to click on the Send Accept button.
- Click on Accept
- Click on Send Accept
- The Deny button should become inactive
I have tried removing the 'option' class from the Deny button after clicking Send Accept, but the button remains active. The issue persists even though the class has been removed :(
Link to my codepen: http://codepen.io/leongaban/pen/hKDIJ
HTML
<div id="accept" class="option btn_accept">
Accept
</div>
<div id="deny" class="option btn_deny">
Deny
</div>
<div id="accept_msg">
<form id="accept_form">
<textarea name="" id="" cols="30" rows="2">ACCEPT! textarea</textarea>
<button id="send_accept">SEND ACCEPT</button>
</form>
</div>
<div id="deny_msg">
<form id="deny_form">
<textarea name="" id="" cols="30" rows="2">DENY! textarea</textarea>
<button id="send_deny">SEND DENY</button>
</form>
</div>
jQuery
$('.option').unbind('click').bind("click", function() {
var user_choice = $(this).attr('id');
// IF ACCEPT
if (user_choice === 'accept') {
$('#accept_msg').slideDown('fast', function() {});
$('#deny_msg').slideUp('fast', function() {});
$('.btn_accept').css('background', 'orange');
$('.btn_deny').css('background', '#ccc');
// IF DENY
} else if (user_choice === 'deny') {
$('#accept_msg').slideUp('fast', function() {});
$('#deny_msg').slideDown('fast', function() {});
$('.btn_deny').css('background', 'blue');
$('.btn_accept').css('background', '#ccc');
}
});
$('#accept_form').unbind('submit').bind("submit", function() {
var btn_send_accept = $('#send_accept');
var btn_deny = $('#deny');
$(btn_send_accept).css('cursor','auto');
$(btn_send_accept).css('background','#ccc');
$(btn_send_accept).text('Sending...');
$(btn_send_accept).attr("disabled", "disabled");
$(btn_deny).removeClass('option');
$(btn_deny).removeClass('btn_deny');
$(btn_deny).addClass('btn-disabled');
});
Any advice or suggestions?