Databases Reference
In-Depth Information
method of the widget is called and this is passed in as a parameter. In this context, this is a special
object that will provide access to important attributes of the dynamic action in JavaScript.
l result.javascript function :=
'function(){' ||
' if (this.browserEvent === ''load''){' ||
' apex.jQuery(document).save value on casdade(''initItem'', this);' ||
' }' ||
'}';
Finally the result variable is returned and the function ends.
RETURN l result;
END save value render;
With the base of the plug-in created, the only other thing needed to complete the plug-in is to add
the JavaScript file to it. You will first need to save the code from Listing 11-3 to a file named
com pluggen save value on cascade.js . Then, if you're not already there, navigate to the Create/Edit
page for the Save Value on Cascade plug-in and complete the following steps as shown in Figure 11-28.
Click Upload New File.
Set File to the file you created: com_pluggen_save_value_on_cascade.js.
Click Upload.
Figure 11-28. Uploading the JavaScript file to the Save Value on Cascade plug-in
As was done with the render function, let's do a walkthrough of the code in the JavaScript file. The
first lines of code both protect references to the $ object and start a jQuery UI widget named
save value on cascade . Although a UI widget was not truly needed in this case, this serves as a good way
to introduce them and makes it easier to expand the plug-in in the future.
(function($){
$.widget("ui.save value on casdade", {
The next couple lines create a function as part of the widget—also known as a method . The function
will be called by the JavaScript in the PL/SQL code when the page loads. It is passed a parameter which
is a reference to this from the Dynamic Action framework. In that context, this is a special object that
provides access to various plug-in related attributes; in this case, the affectedElements attribute was
needed to know which items the plug-in user wants to save the values of. In the beginning of the
function, a local variable is declared to store a reference to this . In the context of a widget method, this
represents the widget object. This is done to allow access to the object later via closure in JavaScript.
Search WWH ::




Custom Search