views:

182

answers:

2

Hi Everyone:

I'm trying to disable a button inside of a form region in Oracle Application Express (Apex v3) in an ajax-ified manner. I'm using jQuery to accomplish the ajax part.

   $('#P16_MYBUTTON').hide();

Doing a view source on the rendered page I noticed that the button doesn't have an ID even though in Apex I've given it a name. I scanned through the rest of the code and noticed that other elements do have an ID. This behavior is somewhat confusing to me.

Any ideas?

+3  A: 

Apex 4.0 does assign an ID to each button automatically. In Apex 3.x you can assign one yourself via the button's Attributes property:

id="P16_MYBUTTON"

If the button is an HTML button then that is sufficient to make it work; if the button is based on a template then you need to ensure that the template definition contains the #BUTTON_ATTRIBUTES# substitution string in an appropriate position - for example:

<a class="myButton" href="#LINK#" #BUTTON_ATTRIBUTES#>#LABEL#</a>
Tony Andrews
Thanks! Worked perfectly. Something else I noticed is that button style has to be set to HTML button for the ID to appear; seems like it won't be given an id if you use the template button.
maximus
It can be - see my updated answer.
Tony Andrews
+2  A: 

I don't know how Apex does its rendering thing, however, you could use another JQuery selector to locate the button, for instance, if you know the ID or html tag name of the direct parent of this button you could use something like:

$('form > button:first').hide()

For future reference, download this refcard:

http://refcardz.dzone.com/refcardz/jquery-selectors

StudiousJoseph
+1 For the very useful refcard!
Tony Andrews
+1 From me too!
maximus