Serenity UI Class
HTML
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://serenityui.com/libs/serenityui/js/serenityui-libs.min.js"></script>
<script src="https://serenityui.com/libs/serenityui/js/serenityui.min.js"></script>
<div id="results">
</div>
<div style="margin-top:20px;">
<span>Learn about this fiddle at:</span>
<a href="http://jsdev.wikidot.com/blog:7" target="_top">Serenity UI Class, Observable and Model</a>
</div>
JavaScript
// Define the Person class.
var Person = serenity.Class.base({
firstName: null,
lastName: null,
constructor: function (firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
},
fullName: {
get: function () {
return serenity.format("{0} {1}", this.firstName, this.lastName);
}
},
greetings: function () {
return serenity.format("Hello, my 123 current name is: {0}.", this.fullName);
}
});
// Instantiate the person class.
var person = new Person("John", "Doe");
// Call the greetings function.
$("#results").html(person.greetings());