Using rbf_getObjectDef in the header

Posted by MaciejA on 31-Jul-2015 05:54

Hi,

I'm trying to create the global array which will hold all my app settings and it will be build in the page's header. It should be accessible for the whole application which I'm building.

I want to use the rbf_getObjectDef to get the object's field structure. When I'm testing that code inside of any page's script element, wrapped in the $(document).ready(),  it is working fine. When I move the same code into hosted file without $(document).ready and attach to the page's header section, then I'm getting the error:

Uncaught ReferenceError: rbf_getObjectDef is not defined 

In the same place I'm using the rbf_selectQuery and it is working without any issues. Even without the $(document).ready(). 

I don't want to use the $(document).ready() in the header because it is not logical to wait until the page is fully loaded, I want to create that array strait away, but then the rbf_getObjectDef is not working. 

Are there any restrictions regarding the scope where the specific client side functions can be run and other can't?

Regards,
Maciej

Posted by Mohammed Siraj on 25-Aug-2015 05:40

For Ajax Metadata API, one needs to explicitly reference metadata.js on a web page. That is,

<script src='../js/metadata.js' type='text/javascript' charset='utf-8'></script>, add to each page.

The same is also documented here:

http://documentation.progress.com/output/Rollbase/index.html#page/rb/ajax-metadata-api.html#

Next, any metadata API function calls should be made only after the metadata.js is loaded into page. That is ensure that you first reference the metadata.js file (ideally as part of page header) and all metadata API function calls are part of script components that follow later.

Else, only if you are constrained & cannot maintain such ordering, you will be required to include metadata API function calls in document ready event, which basically executes after the DOM is loaded &  all referenced script definitions are loaded.

All Replies

Posted by Orchid Corpin on 31-Jul-2015 10:29

Hi MarciejA,

I have tested the API in version 3.2.3.0 from a view page, and yes I am receiving the same error, even I have the $(document).ready(). I have to confirm first to dev if this is a known bug.

<script>
$(document).ready(function() {
	rbf_getObjectDef("product1", callback);
});
  
function callback(data2) {
	alert(data2);
}
</script>

Sorry for the inconvenience.

Regards,
Orchid

Posted by Orchid Corpin on 25-Aug-2015 00:12
Tested in the latest version 4.0.0.0 also getting the same error. Tracking defect as PSC00339538.

Regards,
Orchid
Posted by Mohammed Siraj on 25-Aug-2015 05:40

For Ajax Metadata API, one needs to explicitly reference metadata.js on a web page. That is,

<script src='../js/metadata.js' type='text/javascript' charset='utf-8'></script>, add to each page.

The same is also documented here:

http://documentation.progress.com/output/Rollbase/index.html#page/rb/ajax-metadata-api.html#

Next, any metadata API function calls should be made only after the metadata.js is loaded into page. That is ensure that you first reference the metadata.js file (ideally as part of page header) and all metadata API function calls are part of script components that follow later.

Else, only if you are constrained & cannot maintain such ordering, you will be required to include metadata API function calls in document ready event, which basically executes after the DOM is loaded &  all referenced script definitions are loaded.

This thread is closed