×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    ContentPanel issues wrt Toolkit

    Sorry guys, really silly question has anybody had any difficulty setting/getting the content after creating a ContentPanel. I try to debug it by putting an alert in and asking for the content using .getContent but it returns undefined. If I however use .innerHTML it picks up all the other divs defined as part of the ContentPanel so it is definitely finding the element it just can't use the .getContent. I might be doing something stupid here and wasn't sure if I could use .GetContent from DOM. Any help will be gratefully accepted.


    I define the panel:

    statusScreen = new ListView("idStatusScreen", "Restoring Contacts");
    var infoPanel = new ContentPanel("idStatusPanel", "Status Msgs", "test data", true, true);
    statusScreen.addControl(infoPanel);

    Then later try to get the content

    uiManager.setView(statusScreen);

    var testing = document.getElementById("idStatusPanel").getContent;
    alert(testing);

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: ContentPanel issues wrt Toolkit

    Hi subbiswas,

    the document.getElementById() method actually returns the DOM element associated with your ContentPanel, and not the ContentPanel instance you've created before. So, you cannot call the getContent() method on it, since it is not defined: to use getContent(), you should use the infoPanel variable you've defined above.

    So, you basically have 2 scenarios:
    * if you're dealing with DOM elements, you have to use the innerHTML property
    * if you have a ContentPanel object, you can use its getContent() method (that actually returns contentElement.innerHTML itself)

    Hope it helps,
    Pit

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Re: ContentPanel issues wrt Toolkit

    Apologies it was a stupid question, I worked it out eventually, basically the content node is the lastchild of the ContentPanel so the answer is to use document.getElementById(panelName).lastChild.innerHTML to set the content within the panel. Thanks for the help though

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: ContentPanel issues wrt Toolkit

    Yes, you can access the ContentPanel content element also by that way, even if I would not recommend it: there's no guarantee that a WRTKit update will not change the DOM structure of ContentPanel or any other objects.

    As a hint, if you want to know the exact DOM structure of WRTKit elements, you can look at their JS code: if the first part you'll find something like this (this is from ContentPanel):
    Code:
    // The element hierarchy in a content panel is as follows:
    //
    // rootElement
    //     assemblyElement
    //         captionElement
    //             foldToggleElement
    //                 captionLinkElement
    //                     captionTextElement
    //     contentElement
    Pit

Similar Threads

  1. Several issues developing on WRT 1.0
    By alexheyd in forum Symbian
    Replies: 0
    Last Post: 2009-01-23, 22:00
  2. What is WRT 1.0, 1.1, 1.2 versions?
    By naroori in forum Symbian
    Replies: 2
    Last Post: 2008-12-24, 20:07
  3. Issues with Nokia Mobile Internet Toolkit 4.0 and 4.1
    By abhinavg6 in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2006-08-11, 22:14
  4. Mobile Internet Toolkit 3.1 localhost access issues
    By jowsaki in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2002-08-14, 07:29
  5. Mobile Internet Toolkit 3.1 localhost access issues
    By jowsaki in forum General Messaging
    Replies: 0
    Last Post: 2002-08-14, 05:39

Posting Permissions

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