Hi I have two functions one with one parameter and the other called 'goToMatchDetailPage' with two parameter. I'm trying to get the two variables to the second function but it end up only going to the first parameter and leaving the second one empty and it says 'undefined'.
match.Home and match.Away are the two dynamic variable I want to pass through 'goToMatchDetailPage'. It puts match.Home and match.Away as one variable and I would like them separate.
Here is the code
function generateMatchLink(match){
//<li data-role="list-divider">Divider</li>
var currentDate = match.Date;
var time = match.Time.replace(":00", "");
if(oldDate != currentDate){
//debugger
oldDate = match.Date;
return '<li data-role="list-divider" data-theme="b">\ ' + oldDate + '\ </li><li data-icon="false"><a href="javascript:void(0)'
+ '" onclick="goToMatchDetailPage(\''
+ match.Home + ',' + match.Away +'\')">'
+ ' <div class="ui-grid-a" data-theme="none" style="height:20px">'
+ ' <div class="ui-block-a" style="width:40%">' + match.Home + '</div>'
+ ' <div class="ui-block-b" style="width:20%">' + time + '</div>'
+ ' <div class="ui-block-c" style="width:40%">' + match.Away + '</div></div></a></li>';
}else{
return '<li data-icon="false"><a href="javascript:void(0)'
+ '" onclick="goToMatchDetailPage(\''
+ match.Home + ',' + match.Away +'\')">'
+ ' <div class="ui-grid-a" data-theme="none">'
+ ' <div class="ui-block-a" style="width:40%">' + match.Home + '</div>'
+ ' <div class="ui-block-b" style="width:20%">' + time + '</div>'
+ ' <div class="ui-block-c" style="width:40%">' + match.Away + '</div></div></a></li>';
}
}
Here is the second function
function goToMatchDetailPage(matchHome, matchAway){
//create the html template
var matchPage = $("<div data-role='page' data-url=dummyUrl><div data-role='header'><h1>"
+ matchHome + "</h1></div><div data-role='content'><div data-role='tabs'>"
+ "<div data-role='navbar'>"
+ "<ul>"
+ "<li><a href='#fragment-1'>" + matchHome + "</a></li>"
+ "<li><a href='#fragment-2'>" + matchAway + "</a></li>"
+ "</ul>"
+ "</div>"
+ "<div id='fragment-1'>"
+ "<p>This is the content of the tab 'One', with the id fragment-1.</p>"
+ "</div>"
+ "<div id='fragment-2'>"
+ "<p>This is the content of the tab 'Two', with the id fragment-2.</p>"
+ "</div></div></div>");
//append the new page to the page contanier
matchPage.appendTo($.mobile.pageContainer);
//go to the newly created page
$.mobile.changePage(matchPage);
}