here's something, everything here is code instead of violin.
First of all, as your decleares question, you want the "Wait" button to change to "Cancel", so I removed another button from html
<div> <input type='submit' class="pending" value='Pending' /> </div> <form method="POST" action="yaddaydahdasda" id="form"> {% csrf_token %} <input type="hidden" value="myvalue" /> </form>β
now some jQuery action.
<script type='text/javascript'> $(document).ready(function() { // if jquery dosent load for some reason, form will be visible. Thats why we hide it when on DOM ready $("#form").hide(); }); $(".pending").on('mouseover',function() { $(this).removeClass('pending').addClass('cancel'); $(this).val('Cancel'); $("#form").show(); }); $(".pending").on('click', function(e) { e.preventDefault(); return false; }); $(".cancel").on('click',function() { $(this).removeClass('cancel').addClass('pending'); $(this).val('Pending'); $("#form").hide(); });
That's all! It works like a charm! You might want to add some css to form, for example. make it float next to a button or something like that?
source share