Detail form ID change with record id why_?

jmoises

Active Member
Hello, i just made a javascript function add it to the details_X.js then upload to /components/com_fabrik/js

i am using this to get the value i need:

var v =Fabrik.getBlock('details_10_1').formElements.get('sy2j8_vir_tutores___id').getValue();

i notice in the source code that details_10_1 is the main div block, i test my function and works ok! but when i try in other record my surprise was this not work becasue the _10_1 (the 1) is the record id, then my javascript dont work, i look in all the sorce code of the detail and there is no block details_10 only so what can i do?

i notice this post also but again the detail_X javascript will not work to other people using this.
http://fabrikar.com/forums/index.php?threads/get-the-form-number-and-record-id-javascript.50394/

thanks for any update
 
Thank for the answer troester,

reading this i understand that i can change:

var blockRef = 'details_8';
and because var exact = false; it also read details_8_1 is this correct?

Code:
/**
* Ensure that Fabrik's loaded
*/

requirejs(['fab/fabrik'], function (Fabrik) {

  // The block you want to use
  var blockRef = 'form_8';

  // Should we use an exact match for the blockRef?
  var exact = false;

  var form = Fabrik.getBlock(blockRef, exact, function (block) {

    // This callback function is run once the block has been loaded.
    // The variable 'block' refers to Fabirk.blocks object that controls the form.
    var v = block.elements.get('tablename___elementname').get('value');

    // If your element is in a repeat group its name is prefixed with _0, _1, _2 etc - to get all element values in an array....
    var values = [];
    Object.each(block.elements, function (element, key) {
          if (key.contains('tablename___elementname')) {
            values.push(element.get('value'));
          }
    });
  });
});

but then again in my previus details_x.js file i only use a function() something like this:

myfunction(){
....my code.....
};

where can i insert the myfunction() in that code from the wiki example? i have try diferents ways but i got and errror that my function was not found it.

thanks for any help
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top