This discussion is archived
8 Replies Latest reply: Feb 21, 2013 11:49 AM by KarenH RSS

how to use $x_Toggle with a static region variable?

KarenH Newbie
Currently Being Moderated
I have a region with a static_id = FAVORITES. It has a footer with code to pass the static region id to a page variable:
<script type="text/javascript">
        $s('P110_FAVORITES_ID','#REGION_STATIC_ID#');
</script>
When the page is opened, a region with the following code is run.
<script language="JavaScript" type="text/javascript">
    *// $x_Toggle('R5953131863873231Body');*
 
    $x_Toggle($v('P110_FAVORITES_ID'));
 
  
    $x("P110_SEARCH").focus();
</script>
Essentially, if this is a new report being created, I would like the FAVORITES region to open automatically. If this is an updated report, then it should be CLOSED. When the region id was hardcode 'R595313....Body', it opened. I am trying to replace these hardcode values with a variable...but again, think I have the wrong syntax. Any thoughts?

THanks. Karen
  • 1. Re: how to use $x_Toggle with a static region variable?
    jrimblas Expert
    Currently Being Moderated
    My guess is that it needs to be

    $x_Toggle($v('P110_FAVORITES_ID') + '_body');

    Because the body is what needs to be open and closed. You would need to inspect the HTML to figure out if it's Body or _body or what.

    BUT really what I would do it simply

    $x_Toggle('FAVORITES_body');

    No need to find out the name of the region if you populate the Static ID field in the Region Attributes. See, once YOU enter a value there, APEX will use that for the page and alias the long internal ID number.

    Hope this makes sense.

    Thanks
    -Jorge
  • 2. Re: how to use $x_Toggle with a static region variable?
    KarenH Newbie
    Currently Being Moderated
    Thanks Jorge.

    I just tried the following....but none worked. hmm. Any thoughts. thanks again!
    $x_Toggle('FAVORITES_body');
    $x_Toggle('FAVORITESBody');
    
    $x_Toggle($v('P110_FAVORITES_ID') + '_body');
    $x_Toggle($v('P110_FAVORITES_ID') + 'Body');
  • 3. Re: how to use $x_Toggle with a static region variable?
    jrimblas Expert
    Currently Being Moderated
    Did you type in FAVORITES in the Static ID field?
    Is this a built in theme? If so which one?
    Which region template?

    The exact syntax for body, Body or Body depends on the theme, that's what you need to inspect or do a view source.
    Try that first to see the name.

    Let me know.
    Thanks
    -Jorge
  • 4. Re: how to use $x_Toggle with a static region variable?
    KarenH Newbie
    Currently Being Moderated
    thanks Jorge - and frustrating that there is not a standard for BODY. grr. :)

    The static id for the region has been set to FAVORITES, and I have checked that the value is correctly assigned to P110_FAVORITES_ID in the footer by placing an ALERT in the javascript.

    we use TEMPLATE 13 - Blue Grey....and I think the syntax is BODY based on the temlate code for region:
    <table class="t13FormRegion" cellpadding="0" cellspacing="0" border="0" summary="" id="#REGION_STATIC_ID#" #REGION_ATTRIBUTES#>
    <thead class="t13RegionHeader">
    <tr>
    <th class="t13RegionTitle">#TITLE#<img src="#IMAGE_PREFIX#themes/theme_13/plus.gif" onclick="htmldb_ToggleWithImage(this,'#REGION_ID#Body')" style="margin:0 5px;" class="pseudoButtonInactive" id="FISHHEADER" /></th>
    <th class="t13RegionButtons">#CLOSE#  #PREVIOUS##NEXT# #DELETE##EDIT##CHANGE##CREATE##CREATE2##EXPAND##COPY##HELP#</th>
    </tr>
    </thead>
    <tbody id="#REGION_ID#Body" style="display:none;">
    <tr>
    <td colspan="2" class="t13RegionBody">#BODY#</td>
    </tr>
    </tbody>
    </table>
    Edited by: KarenH on Feb 21, 2013 1:07 PM
  • 5. Re: how to use $x_Toggle with a static region variable?
    jrimblas Expert
    Currently Being Moderated
    Ah! I see the "issue" right away and the source of the frustration. :)

    The template on the top has id="#REGION_STATIC_ID#", but the body of the region uses #REGION_ID# instead of #REGION_STATIC_ID#.

    So change your template to this:
    <table class="t13FormRegion" cellpadding="0" cellspacing="0" border="0" summary="" id="#REGION_STATIC_ID#" #REGION_ATTRIBUTES#>
    <thead class="t13RegionHeader">
    <tr>
    <th class="t13RegionTitle">#TITLE#<img src="#IMAGE_PREFIX#themes/theme_13/plus.gif" onclick="htmldb_ToggleWithImage(this,'#REGION_STATIC_ID#Body')" style="margin:0 5px;" class="pseudoButtonInactive" id="FISHHEADER" /></th>
    <th class="t13RegionButtons">#CLOSE#  #PREVIOUS##NEXT# #DELETE##EDIT##CHANGE##CREATE##CREATE2##EXPAND##COPY##HELP#</th>
    </tr>
    </thead>
    <tbody id="#REGION_STATIC_ID#Body" style="display:none;">
    <tr>
    <td colspan="2" class="t13RegionBody">#BODY#</td>
    </tr>
    </tbody>
    </table>
    Notice I changed it in two places. I changed the Javascript with the ToggleWithImages call.
    Then test it out to make sure it all still works as before. Meaning the toggle works.

    Then, the code I mentioned before using simply $x_Toggle('FAVORITESBody'); will work assuming the Static ID field does contain FAVORITES on it.

    The way the REGION_STATIC_ID works is that if you specify a value in the Static ID APEX will use that. If you leave it empty APEX will use the region's unique ID. So it will always work.
    Because you will be specifying the Static ID name to use there is absolutely no need to find out what the value is or save it to a variable.

    Test is out...
    -Jorge

    Edited by: jrimblas on Feb 21, 2013 1:12 PM
  • 6. Re: how to use $x_Toggle with a static region variable?
    KarenH Newbie
    Currently Being Moderated
    Thanks Jorge!!

    rather than change the template (because it is used over and over with many pages/regions), I instead elimininated the STATIC_ID = FAVORITES in the region.

    I then used :
    <script language="JavaScript" type="text/javascript">
       
          $x_Toggle($v("P110_FAVORITES_ID") + 'Body');
    
          $x("P110_SEARCH").focus();
    
    </script> 
    it worked perfectly. Thank you again. I really appreciate your help. Karen
  • 7. Re: how to use $x_Toggle with a static region variable?
    jrimblas Expert
    Currently Being Moderated
    Just so you know, you can easily copy the template and then modify it if you're worried about the template not working on other areas.
    However, the change I advise you for your template is correct and it's the standard approach for newer templates. The REGION_STATIC_ID option was not always present in APEX and this template predates that. It looked to me that the template was just partially upgraded. If it had been updated correctly you may not be jumping through hoops to accomplish what you wanted to. :)

    All that said, I'm glad it's all working.

    Thanks
    -Jorge

    Edited by: jrimblas on Feb 21, 2013 1:46 PM
  • 8. Re: how to use $x_Toggle with a static region variable?
    KarenH Newbie
    Currently Being Moderated
    interesting! and good to know...once the pressure is off, I will play around more. thanks again.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points