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.

scope - Jquery Dialog issue -


in order use jquery ui dialog module use of $.extend() method , wrote this:

user.confirmationdialog = function(options) {   if(undefined === options.selector)   {       return false;   }    this.close = function()   {     modal.dialog('close');   }    this.forward = function()   {     if(undefined !== trigger.attr('href'))     {       document.location.href = trigger.attr('href');     }   }    var modalbuttons = {};   if(undefined !== options.buttons)   {     for(var buttontitle in options.buttons)     {       modalbuttons[buttontitle] = (function(e, f)       {         return function() {           e.call(f);         }       })(options.buttons[buttontitle], this);     }     delete options.buttons;   }    var modalhtmlelementid = 'confirmdialog';   if(undefined !== options.id)   {     modalhtmlelementid = options.id;     delete options.id;   }    var modaloptions = jquery.extend({     autoopen: false,     width: 410,     height: 'auto',     minheight: false,     dialogclass: 'modaldefault',     modal: true,     resizable: false,     draggable: false,     close: function()     {       bindtriggers();     },     open: function()     {       unbindtriggers();     },     buttons: modalbuttons   }, options || {});    var modal = jquery('<div />', {'id': modalhtmlelementid});   if(undefined !== options.text)   {     modal.html(options.text);   }   modal.dialog(modaloptions);     var trigger = null;   var ontriggerclick = function(e)   {     e.preventdefault();     trigger = jquery(e.target);     if(undefined !== options.beforeopen)     {       options.beforeopen.call(trigger, modal, e);     }     modal.dialog('open');   };    //bind custom event current options.selector elements   var bindtriggers = function()   {     jquery(options.selector).live('click', ontriggerclick);   }    //unbind custom event current options.selector elements   var unbindtriggers = function()   {     jquery(options.selector).die('click', ontriggerclick);   }    //first init: bind custom event listener on option.selector   bindtriggers(); }  /* * * @required user.confirmationdialog */ user.singlebtndialog = function (options) {   if(undefined === options.selector) return false;    var text= options.text,       ok = options.okbtntxt,       dialogbutton = {};    dialogbutton[ok] = function()   {     this.forward();   };    var modaloptions = jquery.extend({     selector: options.selector,     text : text,     closeonescape: false,     open: function(event, ui)     {       jquery(".ui-dialog-titlebar-close").hide()     },     buttons: dialogbutton   }, options || {});   user.confirmationdialog(modaloptions); }  user.twobtndialog = function(options) {   if(undefined === options.selector) return false;    var text= options.text,       ok = options.okbtntxt,       cancel = options.cancelbtntxt,       dialogbuttons = {};    dialogbuttons[ok] = function()   {     forward();   };   dialogbuttons[cancel] = function()   {     close();   };    var modaloptions = jquery.extend({     selector: options.selector,     text: text,     buttons: dialogbuttons   }, options || {});   user.confirmationdialog(modaloptions); };  user.ajaxcontentdialog = function(options) {   if(undefined === options.selector) return false;    var modaloptions = jquery.extend({     selector: options.selector,     beforeopen: function(modal, e)     {       e.stoppropagation();       jquery.ajax({          async: false,          type: 'get',          url: this.attr('href'),          success: function(data, textstatus, xmlhttprequest)          {           modal.html(data);          }       });     }   }, options || {});   user.confirmationdialog(modaloptions); }; 

frontend, i'm binding of 3 methods (singbutton, 2buttons, or ajax) way :

 [user.singlebtndialog, {       okbtntxt: 'ok',       text: 'blablablablabl',       selector: '.addtofav'}],      [user.twobtndialog, {       okbtntxt: 'ok',       cancelbtntxt: 'ablehnen',       text: 'blablablablabl',       selector: '.topicopenclose'}], 

my issue quite simple, yet cannot seem resolve : event binded on each of selectors, buttons created properly, yet, when clicking on 'ok' button, a

trigger null [break on error] if(undefined !== trigger.attr('href'))  

error. suspect scope misunderstanding, can't seem find correct solution.

thanks help, appreciated.

yes, scope issue. try call using user.confirmationdialog.forward(); ifthis not work make function public available.

edit: should make functions objects functions , call functions only.

user.confirmationdialog = {   recent_function: function(options){    // ...  }   close: function()   {     alert('close');   }   ... } 

calling user.confirmationdialog.recent_function run former function confirmationdialog. may acces close using user.confirmationdialog.close();


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 -