The Revealing Module Pattern is an updated Module Pattern where you define all of your functions and variables in the private scope and return an anonymous object at the end of the module along with pointers to both the private variables and functions you wish to reveal as public.
Questions tagged [revealing-module-pattern]
179 questions
0
votes
1 answer
JS: revealing module pattern - accessing internal objects vs arrays?
Using the revealing module pattern, how can I provide direct access to non-static private variables? Here's what I have:
var M = function () {
var obj = {};
var arr = [];
var change = function () {
obj = {"key":"if I see this, O…

o-o
- 8,158
- 2
- 20
- 21
0
votes
2 answers
Setting JavaScript "class" properties from internal function using "this" Keyword?
I am surprised that I could not find more on this topic (could be my sub-par search skills). Typically once I think I understand how the JavaScript keyword, "this" works it then stops working the way I understand. I'll address one such issue.
My…

Gary O. Stenstrom
- 2,284
- 9
- 38
- 59
0
votes
0 answers
telerik using "built-in" jQuery: module pattern
I'm having problems binding events with telerik & jquery. I've found documentation where telerik has it's version of jquery integrated, in this case it's 1.9.1:
$telerik.$(document).ready(function () {
//alert("in telerik doc ready");
…

Will Lopez
- 2,089
- 3
- 40
- 64
0
votes
2 answers
Multiple "classes" in same namespace, but in separate files
I have a namespace: Foo.Bar.Baz within which I have the Qux class. These were defined using the revealing module pattern:
Foo.Bar.Baz = (function ($) { // the namespace/module
function Qux() { // the Qux "class" is contained in this…

Bobby B
- 2,287
- 2
- 24
- 47
0
votes
1 answer
Javascript revealing module pattern Noob
I'm starting Addy Osmani's amazing book on javascript design patterns but can't seem to get off the ground. Can anyone tell me what's wrong here with my approach (I'm using Raphael, just for fun.):
var myPaper = Raphael('container', '800',…

Ben
- 11,082
- 8
- 33
- 47
0
votes
2 answers
JavaScript Revealing Module Pattern Variable Scope
I have an issue where I can't get to a variable inside a function:
EDIT
I forgot to add that I am setting this workerPage.grid = $("#grid").data("kendoGrid"); on the jQuery $(function(){});
I can't use claimsGird variable inside the save function, I…

Sam
- 15,336
- 25
- 85
- 148
0
votes
2 answers
javascript module pattern: add private property to module from private function
How do I fix createBar() so that a private property bar is created at the same level as the property foo?
var x = (function() {
var foo = "a";
function createBar() {
this.bar = "b";
}
return {
getFoo: function() {
return…

Pascal Rosin
- 1,498
- 16
- 27
0
votes
2 answers
How to handle local functions within the revealing module pattern that "return this"
I like the revealing module pattern. I will have private functions that I would like to make public and return them. But I may also have some local functions within my revealing module pattern that "return this"...
var player = function(){
//my…

klewis
- 7,459
- 15
- 58
- 102
0
votes
2 answers
Parameter to Web Service via Jquery Ajax Call
I am using revealing module pattern and knockout to bind a form. When data is entered in that form(registration), it needs to be posted back to MVC4 web method.
Here is the Jquery code
/*
Requires JQuery
Requires Knockout
*/
op.TestCall =…

Shubh
- 6,693
- 9
- 48
- 83
0
votes
2 answers
function parameter undefined in knockout.js
I am using the Revealing Module Pattern to get some structure in my knockout.js code.
It is a very simple Example
Goal: return the value of the Name-Property of the Object.
Problem: The function parameter x is undefined.…

Thomas Deutsch
- 2,344
- 2
- 27
- 36
-1
votes
1 answer
Accessing a module array gives me a reference error
I am trying to understand the revealing-module pattern but when try to update or access the variables falling into errors and can anyone provide an example how to update/access the variables in revealing-module pattern
I get
main.js:20 Uncaught…

bnthsrikanth
- 9
- 1
-1
votes
1 answer
Return in Revealing Module Pattern
I read Addy's book here about revealing module patter. However, if you execute the example code it actually returns undefined. A fix is to add 'return' before each called functions. Am I supposed to add return for each functions being called if…

user2734550
- 952
- 1
- 12
- 35
-1
votes
1 answer
Revealing module pattern: object is undefined
I am trying to implement the revealing module pattern in my js files in IE8. Given this code:
var foo = (function () {
//private members
var a, b, c, d;
var init = function () {
var self = this;
//public members
var A, B, C, D
var…

Xs10tial
- 143
- 2
- 10
-2
votes
1 answer
Revealing module pattern in AngularJS works except for promises
I am working on a project using AngularJS. We are looking at using the revealing module pattern so we can have private functions in our controllers and services. Everything works as expected, except for promises/async data.
Here is an…

A Hobbit
- 62
- 7