Table 4. Methods for the Button Object
|
|
|
|
|
disable() |
this |
Yes |
Disables the button. |
btn.disable();
|
enable() |
this |
Yes |
Enables the button. |
btn.enable();
|
getId() |
String |
No |
Returns the ID of the button. You can use the returned ID to find the button again. |
var sBtnId = btn.getId();
|
getImage() |
String |
No |
Returns the URL to the image that was assigned to the button. |
var sBtnImg = btn.getImage();
|
getParent() |
TitleBar |
No |
Returns the parent TitleBar instance of this button. You can call this method to get the parent TitleBar of a known Button and add more buttons to the TitleBar. |
var tb = btn.getParent();
oraclecrmod.createButton({ id:"NewBtnId",text: "New Button", parent: tb});
|
getText() |
String |
No |
Returns the text of the button. |
var text = btn.getText();
|
getToolTipText() |
String |
No |
Returns the tooltip text of the button. |
var toolTipText = btn.getToolTipText();
|
getToolTipFormat() |
String |
No |
Returns the tooltip format of the button |
var toolTipFormat = btn.getToolTipFormat();
|
hide() |
this |
Yes |
Hides the button. |
btn.hide();
|
invokeDefault (evt) |
Not applic-able |
No |
Invokes the default event handler for the preconfigured button. This is useful if you want to add additional functionality to a preconfigured button, but then still want to invoke the default event handler. For example, you might want to validate a form before the record is saved. You can redefine the onclick event for the Save button to include your own validation logic. After the validation, you still want to save the record, so you can then call invokeDefault("click") on the Save button. |
var btn = oraclecrmod.getButton ("Save Button ID");
btn.offDefault("click").on("click",function(){
if(data is valid){
this.invokeDefault ("click");
}else{
alert("validation failed");
}
});
|
isDisabled() |
Boolean |
No |
Returns whether the button is currently disabled. |
if(btn.isDisabled()){
//do something here
}
|
isHidden() |
Boolean |
No |
Returns whether the button is hidden. |
if(btn.isHidden()){
//do something here
}
|
off(evt,customFunction) |
this |
Yes |
Removes the registered event listener for the given event. NOTE: The event handler must be the original event handler that was used to register the event.
For information about how to define the event handler function, see Defining an Event Handler for a Button. |
btn.off("click",myClickHandler);
|
offAll(evt) |
this |
Yes |
Removes all event handlers attached to the Button for the given event. This method is useful when you want to change the default behavior of a button, for example, to remove the default onclick event. |
btn.offAll("click");
|
offDefault(evt) |
this |
Yes |
Removes the default event handler for the preconfigured button. Because the event handler for preconfigured buttons is not added by the user, you do not have the reference to the original event handler, and so you cannot remove the event handler by calling the off() method. |
btn.offDefault("click");
|
on(evt,customFunction, data) |
this |
Yes |
Registers an event handler for the given event type. The data parameter is an optional parameter. It is useful when you want to pass more information to the customFunction. NOTE: You can use an anonymous function as the event handler. However, in that case, you cannot remove the event handler unless you call offAll(), which removes all the registered event handlers for the given event type. So, if you plan to remove the event handler, then do not use the anonymous function as the event handler.
|
btn.on("click",myClickHandler);
The following sample code uses the optional data parameter: btn.on("click", function(evt, customerNumber) {alert(customerNumber); }, 1234);
In this case, the additional data, 1234 , is passed to the custom function through the customerNumber parameter. For a further example of using the on() function, see Defining an Event Handler for a Button. |
setImage(url) |
this |
Yes |
Sets an image for the button. You can use a relative URL or absolute URL for an image. If the URL is null, then the image is removed. |
btn.setImage("http://domain/imgs/img.gif");
or
btn.setImage("/images/test.png");
|
setParent(tb) |
this |
Yes |
Sets the given TitleBar as the parent of this button. You can create a button first, without giving it a parent. You can then call this method to add the button to a TitleBar. If a button is already added to a TitleBar, and if you call this method for a different TitleBar, then the calls fails and an alert is displayed. |
btn.setParent(titlebar);
|
setText(text) |
this |
Yes |
Sets the text of this button. No text is displayed if a null or empty string is passed. |
btn.setText("Text is Changed");
|
setToolTipText(toolTipText) |
this |
Yes |
Sets the tooltip text of the button. If a null or empty string is passed, no tooltip is set for this button. NOTE: If you use oraclecrmod.enableIdHint() in your code, the tooltip for enableIdHint() is displayed on top of the tooltip text for setToolTipText().
|
btn.setToolTipText ("Tool Tip Text for Button");
|
setToolTipFormat() |
this |
Yes |
Sets the tooltip format of the button, which can be either HTML or plain text. If a null or empty string is passed, the format is set as Plain Text . The default value is Plain Text. |
btn.setToolTipFormat ("HTML");
For more information about tooltip formatting, see Considerations for Specifying Tooltips with HTML Formatting.
|
show() |
this |
Yes |
Shows the button if the button is currently hidden. |
btn.show();
|