Thread: Scope Issue

    #1
  1. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128

    Scope Issue


    Code:
                        $(content).find("[name^='"+$(frame).attr('segment')+"']").each(function(frame){
                            var segment = $(frame).attr('segment');
                            var num = $(frame).attr('num');
                            var oldName = $(this).attr('name');
                            var newName = segment.replace(/^(.*)\]$/,'$1-'+num+']');
                            $(this).attr('name',oldName.replace(segment,newName));
    console.log($(this));
                        },[$(frame)]);
    console.log($(content));
    So I have 'content' that's pulled from .html() of another element and the each-loop above is designed to update the 'name' attribute of all elements within it.

    This works fine. The first console.log() shows an object in which the 'name' attributes have been correctly replaced.

    But the changes don't seem to be committed to the 'content' object--or its descendants, to be more accurate--as revealed by the second console.log().

    I swear this was working earlier, but it's not now. And I have no idea why. Am I just overlooking something stupid?

    Thanks
    LinkedIn: Dave Mittner
  2. #2
  3. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Disregard. I seem to have figured it out.
    LinkedIn: Dave Mittner

IMN logo majestic logo threadwatch logo seochat tools logo