Friday, May 9, 2014

Debugging

Yesterday I ran through the website again, doing some randomized testing (i.e. just clicking on buttons in no particular order to make sure things are working) and found an issue with challenges that have parent challenges (i.e. where there are levels of challenges). If, for example, you click a level 2 challenge and you have not yet taken the level 1 challenge, the display modal just shows a button saying "View Parent Challenge". However, I discovered that this button was not actually "hooked up" to anything. So, I spent about an hour googling around and trying to figure out how to get a modal to refresh its content while it is being displayed. After some frustration, I found that some simple jQuery:

  $(document).ready(function(){
    $('.modal-id-here').on('hide.bs.modal', function () {
      $('.modal-id-here').removeData();
    });

  });

worked perfectly. It clears out the old content so that the new content can be loaded (in this case, the new content is the information about the parent challenge).

As I was testing this fix, I found some problems with the .csv file that is used to seed the challenges in the database. Some of the challenges were not having their parent challenges set properly and therefore were not being displayed as child challenges in the application. I went through the list and fixed this issue so that the challenges will now be correctly associated with their parent.

No comments:

Post a Comment