Skip to main content

Posts

Showing posts with the label JavaScript

Revealing Module Pattern in JavaScript

Revealing Module Pattern makes the code to read better and more structured way, This really useful when we had to repeat the name of the main object when we wanted to call one public method from another or access public variables. This is done by adding a return statement at the end of the function that exposes the public members. The benefits of this approach are. The Revealing Module Pattern allows the syntax of your script to be fairly consistent - it also makes it very clear at the end which of our functions and variables may be accessed publicly, something that is quite useful. In addition, we also able to reveal private functions with more specific names if we wish. The following code demonstrates how the module can be revealed. var myModule = (function () { var name = 'Mohamed Rafeeq'; var age = 28; function updatePerson() { name = 'Mohamed Rafeeq Updated'; } function setPerson() { name = 'Mohamed Rafeeq Set...

knockoutjs with Umbraco and Umbraco base call

I was thinking how we could use knockoutjs with Umbraco, so just thought blog it. Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably. Features Elegant dependency tracking Declarative bindings Flexible and sophisticated templating Trivially extensible More information reference: http://knockoutjs.com . Well, we start with Umbraco, To know more on umbraco, Please refer below links http://our.umbraco.org/wiki/how-tos/a-complete-newbie's-guide-to-umbraco http://umbraco.com/help-and-support/video-tutorials/getting-started?freeVideos=1 http://our.umbraco.org/wiki/how-tos/getting-started-with-umbraco-what-is-next-after-you-install http://our.umbraco.org/wiki/install-and-set...

Error: ko.mapping.updateFromJS, use ko.mapping.fromJS instead

I had the same issue, (Error: ko.mapping.updateFromJS, use ko.mapping.fromJS instead) I bugged for long time, then i tried the another alternative. fromJS  the functionality is the same, but be aware that updateFromJS's parameter list is just the other away around, so instead of doing:    ko.mapping.updateFromJS( viewModel, jsData); You need to replace this with:    ko.mapping.fromJS( jsData, {}, viewModel );