Joomla prefix in JavaScript

Hi guys,

Is there a way to get the joomla table prefix in FORM Javascript files placed in the "\components\com_fabrik\js" folder?

I have a couple of js files that set a URL for a button and need to construct a URL filter:

JavaScript:
        var form = Fabrik.getBlock('form_11', false, function(form) {
        var el = form.elements.get('pre_mytable___my_id');
        var val = el.getValue();
        // more code
}

Any chance of getting the prefix so I can substitute "pre" with the actual prefix?

Could I add a "global" variable in JS using php to generate something like this in one of the event handler for the php plugin?

PHP:
$joomlaPrefix = JFactory::getApplication()->application->get('dbprefix');
return('<script>var joomlaPrefix = "' . $joomlaPrefix . '"</script>');

Best regards,
Arnor
 
Hi guys,

Using a JavaScript global variable works like a charm! I added this to my form:

PHP:
  $jS = '<script type="text/javascript">' .
        'var joomlaPrefix="' . JFactory::getApplication()->get('dbprefix') . '";' .
        '</script>';
  echo($jS);

in the "When the form JS is asembled and ready during page load" plugin. Then in my form9.js file I tested for the value and it contains the joomla prefix!!! :)

Best regards,
Arnor
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top