SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    YUI to Microsoft Ajax

    I'm trying to migrate but i have a couple of headaches.

    I couldn't find getElementsByClassName in the library.... i wrapped YUI's version in my own namespace for the moment.


    I'm pulling my hair out trying to work with events in MS ajax.
    Previous in YUI
    PHP Code:
    gridviews[i].objResizeGridViewColumns = new RobustHaven.Domains.Web.Controls.GridView.ResizeGridViewColumns(gridviews[i]);
    gridviews[i].objResizeGridViewColumns._init();




    RobustHaven.Domains.Web.Controls.GridView.ResizeGridViewColumns = function(gv)
    {

        
    this._init = function()
        {

            
    YAHOO.util.Event.addListener(columns[i], 'mousemove'this._onMouseMovethistrue);
            
    YAHOO.util.Event.addListener(columns[i], 'mousedown'this._onMouseDownthistrue); 

    attempt to convert the yui calls to ms ajax but events aren't being raised anymore...
    PHP Code:
            Sys.UI.DomEvent.addHandler(columns[i], {
                
    mousemove:this._onMouseMove,
                
    mousedown:this._onMouseDown
            
    }, this); 


    my goal is just to encapsulate my event functions to avoid collisions with other script events.

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i always use the ICallBackEventHandler

    ...I believe thats what its called...
    Web Application Development & Maintenance

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MicrosoftAjax uses extenders

    basically you need to use
    http://www.asp.net/ajax/ajaxcontrolt...wExtender.aspx


    the idea is "this" is the dom element
    e._behavior.<yourmembervariableORyourmemberfunction>
    args = event containing mouseover, mousedown arguments


    PHP Code:
    Sys.UI.DomEvent.addHandler(this._ths[i], 'mousedown', Function.createCallback(this._onMouseDownargs));


        
    _onMouseDown : function(argse){
            
    //  if the user clicks the mouse button while
            //  the cursor is in the resize position, it means
            //  they want to start resizing.  Set this._isResizing to true
            //  and grab the th element that is being resized
            
    if(args.target.style.cursor == 'e-resize') {
                
    e.behavior._isResizing true;
                
    e.behavior._element args.target;
            }                    
        }, 

    see http://blog.lavablast.com/post/ASPNE...-resizing.aspx

    very cool how microsoft has handled this.
    Almost gets rid of needing a search for dom elements with a common css name. You have more control on exactly which control you want to apply javascript to.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •