I am making an jQuery Mobile / Phonegap application that has two pages. The first page has a search input, where the user can add a book name, or author, and then the second page is where the results are shown depending on how many match the given value.
Till now I have manged to get the value from the search input, and receive the value in the second page successfully.
My jQuery code is on external files, and are added to the index.html file between jQuery.js and jQuerMobile.js
//this is from the first page
// capture the user input, and change page to search_results.html
function handlePageChange() {
if ($('#search-1').val().length > 0) {
$.mobile.changePage('search_results.html', {
dataUrl : "search_results.html",
data : {
'input' : $('#search-1').val()
},
reloadPage : false,
changeHash : true
});
} else {
alert('Search input is empty!');
}
}
//Handle the page-change action after user has pressed the button = changePage
$(document).on('pagebeforeshow', "#index", function() {
$(document).on('click', "#changePage", handlePageChange);
});
//this is from second page
// get data from search input form index.html
function getSearchValue() {
var parameters = $(this).data("url").split("?")[1];
parameter = parameters.replace("input=", "");
alert(parameter);
}
//Trigger after page is loaded
$(document).on('pageshow', "#search_results", getSearchValue);
But I am stuck on two things. First looking at the jQueryMobile it confuses me as if, which event to use to use my ajax call to the API.
Should I just just another callback function to the existing event listener pageshow
.
Then I want to populate my listview
with the results from Google Books API, but I can't find any good examples out there.
And least, I want to show the books, in listview
with thumbnail, and title, and when someone clicks on one of the books, it will be transitioned to another page where it shows more details about the book.
How can I do that depending on the id.
Even concept without code are welcomed. Thank you