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 - Problem with Event Handling via YUI -


when users click "search" input element, search text inside input disappear , since have several controls that, thought make code reusable. here code formerly done , working jquery in yui cannot make work.

var subscriptionboxtarget = "div.main div.main-content div.side-right div.subscription-box input"; var ssbnode = yahoo.util.selector.query(subscriptionboxtarget); var ssbvalue = yahoo.util.dom.getattribute(ssbnode,"value"); var subscriptionbox = new removabletext(ssbnode,ssbvalue,null); subscriptionbox.bind(); ////////////////////////////////  //target : target of element dispatches event // defaulttext : default input[type=text] elements // callback : function run after everthing completed function removabletext(target,defaulttext,callback) {     var target = target; //private members      var defaulttext = defaulttext;     var callback = callback;      //instance method     this.bind = function()     {         mouseclick(target,defaulttext);         mouseoff(target,defaulttext);         if(callback != null)             callback();     }      //private methods     var mouseclick = function(eventtarget,defaultvalue)     {         var _eventtarget = eventtarget;         var _defaultvalue = defaultvalue;         /*$(eventtarget).bind("click",function(){             var currentvalue = $(this).val();             if(currentvalue == defaultvalue)                 $(this).val("");         });*/          yahoo.util.event.addlistener(_eventtarget,"click",function(e){             alert(e);          });     }      var mouseoff = function(eventtarget,defaultvalue)     {         var _eventtarget = eventtarget;         var _defaultvalue = defaultvalue;         /*$(eventtarget).bind("blur",function(){             var currentvalue = $(this).val();             if(currentvalue == "")                 $(this).val(_defaultvalue);         });*/          yahoo.util.event.addlistener(_eventtarget,"blur",function(e){             alert(e);          });     }    }  

you have lot of unnecessary code here.

the input parameters passed removabletext constructor available closure methods defined inside. don't need to, , shouldn't redefine named params vars.

function removabletext(target, defaulttext, callback) {     this.bind = function () {         yahoo.util.event.on(target, 'click', function (e) {             /* can reference target, defaulttext, , callback in here */         });          yahoo.util.event.on(target, 'blur', function (e) { /* , here */ });          if (callback) {             callback();         }     }; } 

the definition of instance method within constructor seems dubious, requirement values passed constructor must kept private. assign them instance properties (this._target = target; etc) , add instance methods prototype. if functionality you're after simple, why bother methods @ all?

using click event not support keyboard navigation. should use focus event.

i'm not sure why have callback passed @ construction fires after attaching event subscribers.


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 -