I like to know if this can be allowed as map function will not work
jQuery(document).ready(function()
{
Mypage1.initMap();
Mypage2.initMap();
}
);
I like to know if this can be allowed as map function will not work
jQuery(document).ready(function()
{
Mypage1.initMap();
Mypage2.initMap();
}
);
Hi,
It should do:
test.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="test.js"></script>
<script>
$(document).ready(function(){
Mypage1.initMap();
Mypage2.initMap();
});
</script>
</body>
</html>
test.jsvar
Page = function(page){
this.page = page;
};
Page.prototype.initMap = function(){
console.log("Map initialized from page " + this.page);
};
var Mypage1 = new Page(1);
var Mypage2 = new Page(2);
Output
Map initialized from page 1
Map initialized from page 2
As this was simple issue how to add additional init functions other that init Map:
You have now: Page.prototype.initMap = function() {
I have additional int function for other pages:
Mycontact.initContactForm1();
How to change in the correct way (test.js)?
What’s not working for you?
I have tested your basic script. It will work as error message is not shown. Issue is that map will not be shown inside both pages. I’m not sure but as it would block init maps.
When I remove your code it will work maps but as posted I have to hide one init map to work.
Whole code is the following:
*
var Page = function(page) {
this.page = page;
};
Page.prototype.initMap = function() {
console.log("Map initialized from page " + this.page);
};
var Mypage1 = new Page(1);
var Mypage2 = new Page(2);
*
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.