SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Class problem

  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Class problem

    Using Prototype
    Code:
    AjaxPreview = Class.create();
    
    AjaxPreview.prototype =
    {
        initialize: function(id, div, iframe)
        {
            this.form = id;
            this.div = div;
            this.iframe = iframe;
    
            $(id).addClassName('viewForm');
            Event.observe(id, 'submit', this.router);
        },
    
        router: function()
        {
            alert(this.form);
        }
    }
    and setting up like this:

    HTML Code:
                <input type="submit" id="submit" name="submit" value="Generate Preview" />
            </form>
            <!-- SET UP AJAX PREVIEW -->
            <script type="text/javascript">
                var preview = new AjaxPreview('preview', 'upload', 'frame');
            </script>
        </body>
    </html>
    When I submit the form the alert that comes up shows undefined, but it should show the ID of the form that was set with the new AjaxPreview().

    I honestly don't have a clue why it's not working. Any help would be great.

    PS. the router method is just testing that the variables are set at the moment. It'll be used for something different later on haha.
    hmm...

  2. #2
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah never mind I've figured it out via this link.
    hmm...


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
  •