www.webdeveloper.com
Results 1 to 4 of 4

Thread: Beginner Using Basic OOP

  1. #1
    Join Date
    Jun 2013
    Posts
    15

    Beginner Using Basic OOP

    Hello

    I am new to javascript, and extremely new to OOP

    The script below is meant to run the same function twice, it's a highslide gallery and uses a for loop to write the same statement either 12 or 15 times depending on which apartment,


    <br />
    // Build Class
    function buildgal() {

    this.method1 = function method1(apartment,amount) {

    for (var i = 0; i <= amount; i++)
    {
    $('.' + apartment).append('<li> <a href="highslide/' + apartment + '/C1 (' + i +').jpg" class="highslide" title="" onclick="return hs.expand(this, config1 )"> <img src="highslide/' + apartment + '/thumbs/C1 (' + i +').jpg" alt=""/> </a> </li>');
    }
    }
    }
    // Class Ends

    // Create Instances

    var instance1 = new buildgal();
    var instance2 = new buildgal();

    // Call Method

    instance1.method1('cal',15);
    instance2.method1('pent',12);



    <br/>


    Here is the html snippet which Is where I would like the html to appear from the for loop statment.

    <br />
    <div style="width:100%; margin-left:20px;" class="highslide-gallery">
    <ul class="cal">



    </ul>
    </div>
    //////////////////////////


    <div style="width:100%; margin-left:20px;" class="highslide-gallery">
    <ul class="pent">
    </ul>



    </div>


    <br />


    If I change the append statement to alert(i) it cycles through the function 15 and 12 times as it should,

  2. #2
    Join Date
    Jun 2013
    Posts
    15
    Apologies for next placing the code in the correct tags for formatting reasons, how can I edit my initial post?

  3. #3
    Join Date
    Jun 2013
    Posts
    15
    Hello

    I am new to javascript, and extremely new to OOP

    The script below is meant to run the same function twice, it's a highslide gallery and uses a for loop to write the same statement either 12 or 15 times depending on which apartment,


    [
    // Build Class
    function buildgal() {

    this.method1 = function method1(apartment,amount) {

    for (var i = 0; i <= amount; i++)
    {
    $('.' + apartment).append('<li> <a href="highslide/' + apartment + '/C1 (' + i +').jpg" class="highslide" title="" onclick="return hs.expand(this, config1 )"> <img src="highslide/' + apartment + '/thumbs/C1 (' + i +').jpg" alt=""/> </a> </li>');
    }
    }
    }
    // Class Ends

    // Create Instances

    var instance1 = new buildgal();
    var instance2 = new buildgal();

    // Call Method

    instance1.method1('cal',15);
    instance2.method1('pent',12);



    <br/>


    Here is the html snippet which Is where I would like the html to appear from the for loop statment.

    <br />
    <div style="width:100%; margin-left:20px;" class="highslide-gallery">
    <ul class="cal">



    </ul>
    </div>
    //////////////////////////


    <div style="width:100%; margin-left:20px;" class="highslide-gallery">
    <ul class="pent">
    </ul>



    </div>

    ]

    If I change the append statement to alert(i) it cycles through the function 15 and 12 times as it should,

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    You are asking a question about JavaScript and what you have is a framework which is a question to ask in the JScript frameworks forum...
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles