RandomlyKnighted's Profile User Rating: -----

Reputation: 118 Stalwart
Group:
Authors
Active Posts:
1,379 (0.62 per day)
Joined:
14-January 10
Profile Views:
60,305
Last Active:
User is offline Nov 12 2015 08:59 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Ford
Dream Kudos:
300

Latest Visitors

Icon   RandomlyKnighted chilling at home working on a jQuery plugin :D

Posts I've Made

  1. In Topic: Migrating OOP knowledge to JavaScript and jQuery

    Posted 25 Sep 2015

    Thanks for the link andrewsw. By the way, the Javascript.isSexy is one of the blogs I was reading when I figured out what I was doing wrong on the scope issue. I'm loving their tutorial posts.
  2. In Topic: Migrating OOP knowledge to JavaScript and jQuery

    Posted 25 Sep 2015

    I thought I'd provide an update in case anyone coming along wants to know what I did to resolve that particular issue. First, I clearly had forgotten that even though I'm creating global variables inside my IIFE they are just global to all the other code inside the IIFE. To the rest of my application those variables (or in my case functions) are local variables that cannot be accessed. So to fix this I added the following to my IIFE:

    // Attach the constructor to the window if it doesn't already exist
    window.Wysiwyg = window.Wysiwyg || Wysiwyg;
    
    


    This allows my Wysiwyg function to be accessible outside the IIFE.

    While that does fix the errors I'm was getting I've now introduced some logic bugs to the code. One thing I'm still a bit confused on is the this keyword. In the past when calling this from within a function it gave me the element that my function was called on. In the examples that I've got the wysiwyg was called on a div. So when I would watch the variable this in the dev tools the div would be what would show up. Now this just gives me the Wysiwyg function. Is there a way to get the element it was called on again?
  3. In Topic: Migrating OOP knowledge to JavaScript and jQuery

    Posted 16 Sep 2015

    I don't get it. When my two lines were in the IIFE it was in scope. How is the scope different now?
  4. In Topic: Migrating OOP knowledge to JavaScript and jQuery

    Posted 15 Sep 2015

    I pulled the code into the IIFE as suggested and worked until I cleared up all the errors. In order to keep things consistent with how the project has worked in the past I changed the code to the following:

    var wysiwyg = new Wysiwyg();
    $('#editor').wysiwyg;
    
    


    I then moved the code back into the HTML file and am getting the error
    ReferenceError: Wysiwyg is not defined
    
    which is occurring on this line:
    var wysiwyg = new Wysiwyg();
    
  5. In Topic: Migrating OOP knowledge to JavaScript and jQuery

    Posted 15 Sep 2015

    Quote

    So move the code inside the IIFE


    That code is not part of the library itself. It's how the developer will be using the library. Should it not stay outside the IIFE?

My Information

Member Title:
D.I.C Lover
Age:
24 years old
Birthday:
June 11, 1991
Gender:
Location:
Albertville, AL
Years Programming:
5
Programming Languages:
ASP.NET, C#, Java, SQL

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://tylerhughes.info
LinkedIn:
http://www.linkedin.com/in/thughes01
Twitter:
thughesIT

Comments

Page 1 of 1
  1. Photo

    ishkabible Icon

    26 Jun 2011 - 18:13
    happy belated birthday!!
  2. Photo

    chinalwb Icon

    07 Jun 2011 - 21:33
    Your birthday is coming, Happy Birthday to You~!
  3. Photo

    no2pencil Icon

    11 Apr 2011 - 19:57
    GO BLUEJAYS!
  4. Photo

    Dogstopper Icon

    05 Nov 2010 - 03:58
    GO BRAVES!
Page 1 of 1