忍者。
我想知道两件事。
如何调用函数“Initialize()”和“FillValidateView()”。我在下面的代码中写了我想调用这些函数的地方。
我是 JavaScript 编程的新手。我想知道以下代码是否适合实现页面转换。
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="header">
<p></p>
</div>
<div id="main">
<div id="validate_or_import">
<input type="button" id="go_validate" value="Validate Data">
<inp ut type="button" id="go_import" value="Import Data">
</div>
</div>
</body>
</html>
JavaScript
$(function () {
var View = function () {
this.title = ''
};
View.prototype = {
Initialize: function () {
this.title = '';
this.tiles = [];
$('#main').children().hide();
},
Render: function () {
$('#header p').html(this.title);
jQuery.each(this.tiles, function () {
this.show();
});
},
FillFirstView: function () {
this.title = 'Select what you want';
this.tiles.push($('#validate_or_import'));
$('#go_validate').on('click', function () {
// I want to call 'Initialize()' and 'FillValidateView()' here!!!!!
});
$('#go_import').on('click', function () {
alert('Not implemented yet');
});
},
FillValidateView: function () {
this.title = 'Validate data';
//I will write more about this view
}
};
var view = new View();
view.Initialize();
view.FillFirstView();
view.Render();
});