Tuesday, March 3, 2015

Changes 3/3/15 - LibriFox Clickable search results

Over the weekend Finn and I actually worked on our project! We solved a bug where our list results wouldn't show up on the html page, even though our json was loading correctly. We thought it was a problem with the listview not refreshing (jquery mobile adds styles to list items, so you have to call $('ul').listview('refresh') after you've appended new items), but it turned out that the problem had nothing to do with jquery mobile. What was happening was upon searching for an item, you are submitting a form, and the default html action for a form submit is to reload the page. Therefore, we were appending all these list items, only to have the page refresh and clear them. We just had to add one line to app.js and our problem went away. This works because the return value for the event listener determines whether the action succeeds or not, so by returning false we are effectively cancelling the form submit and therefor the refresh.

Today, Finn and I worked on the behavior of the list items when you click them. We first had to research how jQuery mobile handles page change events, since it only changes the content of the html page, not the page itself like a "normal" website. Each list item is generated with jQuery, and a custom attribute called book-id is added. Then, when the button is clicked, this book id is saved into local storage for later use. Then, Finn worked on an event that would fire when the books.html page was loaded, which could grab the book id that my onClick event had gotten.

I also tried to make a cool navbar for my blog that would link to my website and github, but apparently you can't even set the background color of links in blogger's header field, which is dumb.  Here's what I was going to add, because I think it looks good:

WebsiteGithub

No comments:

Post a Comment