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.

Flow control in JavaScript -


is possible write flow control in javascript?

mylib.get = function() { /* */ next(); }; mylib.save = function() { /* */ next(); }; mylib.alert = function() { /* */ next(); };  mylib.flow([   mylib.get(),   mylib.save(),   mylib.alert() ], function() {   // functions executed }); 

yes, 2 things know:

  1. you should build array references functions. means leave off (), because want pass through reference, not result of calling function!
  2. you're going have deal fact getting references functions properties of object not "remember" relationship object. thus, "flow" code have no way know how invoke functions "mylib" this context reference. if that's important, you'll want create functions run "member" functions in right context.

to run functions in right context, can cobble "bind" function supplied prototype framework (and also, among many others, functional.js), or $.proxy() jquery. it's not hard , this:

function bindtoobject(obj, func) {   return function() {     func.apply(obj, arguments);   } } 

then you'd use this:

mylib.flow([   bindtoobject(mylib, mylib.get),   bindtoobject(mylib, mylib.save),   bindtoobject(mylib, mylib.alert) ]); 

if need parameters passed in, modify "bindtoobject":

function bindtoobject(obj, func) {   var presuppliedargs = array.prototype.slice.call(arguments, 2);   return function() {     func.apply(obj, presuppliedargs.splice(arguments));   } } 

that assumes you'd want additional arguments passed when "bound" function called tacked on end of argument list. in case, doubt you'd want that, leave off "splice()" call.


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 -