Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - Why aren't options being overridden? -


in module pattern, options 'undefined' reason.. see why aren't being passed in properly?

framework.mymodule = (function(options) {     var defaults = {         someoption : 1,         stuff      : 2     };     if (!options) {         var options = defaults;     } else {         (var index in defaults) {             if (typeof options[index] == 'undefined')                 options[index] = defaults[index];         }     }     var module = {};      // initialize     _something();      // private methods     function _something() {}      // public methods     module.click = function() {};      return module; })();   ... docready function ...  var options = {   someoption : 9,   stuff      : 10 };  framework.mymodule(options);  ... end doc ready ... 

please see fiddle: http://jsfiddle.net/kwhez/1/

var options = { /* ... */}; framework.mymodule = (function(options) {   /* .. options undefined ... */ })();  framework.mymodule = (function(options) {   /* .. options defined... */ })(options); 

now if want ability add private/public variables , still pass options need make constructor method returned public object - not passing options in function run immediately. because lets honest .. doesn't really make sense.


you this:

var module = {}; module.foo = (function($){ // jquery accessible $     var _private = {         defaults: {             url: '/default-url', container: '#dummy'         },         foos: []     };      return function(o){ // returns constructor         // other _private variables accessible here         var opts = $.extend({}, _private.defaults, o);         var self = { // public return object             load: function(){                 $(opts.container).load(opts.url);             }         };         _private.foos.push(self);         return self;     }; })(jquery); // scope global variables   var foo1 = module.foo({     url: '/test.php',      container: '#success' });  var foo2 = module.foo({     url: '/test2.php',      container: '#success2' });  foo1.load(); foo2.load(); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -