updating code from attr to prop

updating code from attr to prop

In the process of moving some jquery code to a site that uses a newer version of jquery, I had to change from using attr to prop as shown below.  

  1. jquery-1.3.2.js
  2. if (!($("[name=jobs_ws]").attr("checked"))) {

  3. jquery-1.10.2.js
  4. if ($("[name=jobs_ws]").prop("checked")) {

After reading up on attr vs prop I'm still unclear on which attr and removeAttr should be clanged to prop in the code below. Currently the only problem is that only in IE11 the checkbox for "phone_appointment" and "have_file" are not being populated with a check when data.phone_appointment=='t' and data.have_file=='t'. In Chrome there is a check in the box, if they are equal to true.

  1. $(".open").click(function(event){
  2. //the time of the appointment is stored in the href of the open link
  3. $("#time").attr("value",$(this).attr("href"));
  4. $("#counselor_name").attr("value",$(this).attr("title"));
  5. $("#formWindow").attr("title","Set New Appointment");

  6. //cancel the normal click behavior (following the link)
  7. event.preventDefault();

  8. //Clear data and Show the form
  9. $("#phone_appointment").removeAttr('checked');
  10. $("#have_file").removeAttr('checked');
  11. $("#email_address").attr("value",'');
  12. $("#phone_number").attr("value",'');
  13. $("#timezone").attr("value",'');
  14. $("#creator_initials").attr("value",'');
  15. showForm();
  16. });


  17. $(".full").click(function(event){
  18. clicked = $(this);
  19. //stop the default click behavior
  20. event.preventDefault(); 
  21. $("#time").attr("value",$(this).attr("href"));
  22. $("#counselor_name").attr("value",$(this).attr("title"));
  23. $("#date").attr("value",selectedDate);
  24. $("#formWindow").attr("title","Edit Appointment");

  25. //POST TO LOOKUP.PHP for information
  26. $.post('lookup.php',{date:selectedDate,time:$(this).attr("href")},function(data){
  27.    $("#time").attr("value",data.appointment_time)
  28.    $("#email_address").attr("value",data.email_address);
  29.    $("#creator_initials").attr("value",data.creator_initials);
  30.    $("#phone_number").attr("value",data.phone_number);
  31.  
  32.    if(data.phone_appointment=='t'){
  33.   $("#phone_appointment").attr("checked","true");  
  34.    } else {
  35.   $("#phone_appointment").removeAttr('checked');  
  36.    }
  37.    
  38.    if(data.have_file=='t'){
  39.   $("#have_file").attr("checked","true");  
  40.    } else {
  41. $("#have_file").removeAttr('checked');
  42.    }
  43. },"json");
  44. showForm('full');
  45. });

Thanks