Hide element in detailed view with js

Status
Not open for further replies.

bea

Active Member
Hi,
I can't find a solution to hide also the element 'comment_sec' in detailed view.
I remembered in F2 the _ro elements ...
I've found this snippet, but it doesn't work. I've tried to put this on different positions...
Cheers,
Bianka

JavaScript:
if (!Fabrik.blocks.has('form_1')) {
    form_1 = details_1;
}

JavaScript:
function hidecomment_sec(el) {
   var elA = el.form.formElements.get('fab_cp1_line_tour___comment_sec');
   var elB = el.form.formElements.get('fab_cp1_line_tour___security_check');

   if (!Fabrik.blocks.has('form_1')) {
    form_1 = details_1;
}
  
    if (elB.getValue() === '') {
      elA.hide();
      return;
   }
  
   if (elB.getValue().toInt()  <= '2') {
      elA.show();
      return;
   }
  
     if (elB.getValue().toInt()  > '2') {
      elA.hide();
   }
   else {
      elA.hide();
   }
}
 
Try ...

Code:
function hidecomment_sec(el){
   var form = Fabrik.getBlock('form_1');
   if (form === false) {
      form = Fabrik.getBlock('details_1');
   }

  if (form === false) {
    // meh, bail out
    return;
   }

   var elA = el.form.formElements.get('fab_cp1_line_tour___comment_sec');
   var elB = el.form.formElements.get('fab_cp1_line_tour___security_check');

   if(elB.getValue()===''){
      elA.hide();
     return;
   }

   if(elB.getValue().toInt()<='2'){
      elA.show();
     return;
   }

     if(elB.getValue().toInt()>'2'){
      elA.hide();
   }
   else{
      elA.hide();
   }
}

If you want to show/hide the whole element rather than just the value ...

Code:
jQuery(elA.element).closest('.fabrikElementContainer').hide();

-- hugh
 
Hi Hugh,
many thanks for the script. I was offline some days and made a test today.
The element is still visible in detailed view, when it should be hidden.
Cheers,
Bianka


JavaScript:
function hidecomment_sec(el){
   var form = Fabrik.getBlock('form_1');
   if (form === false) {
      form = Fabrik.getBlock('details_1');
   }

  if (form === false) {
    return;
   }

   var elA = el.form.formElements.get('fab_cp1_line_tour___comment_sec');
   var elB = el.form.formElements.get('fab_cp1_line_tour___security_check');

   if(elB.getValue()===''){
      jQuery(elA.element).closest('.fabrikElementContainer').hide();
     return;
   }

   if(elB.getValue().toInt()<='2'){
      jQuery(elA.element).closest('.fabrikElementContainer').show();
     return;
   }

     if(elB.getValue().toInt()>'2'){
      jQuery(elA.element).closest('.fabrikElementContainer').hide();
   }
   else{
      jQuery(elA.element).closest('.fabrikElementContainer').hide();
   }
}
 
Where do you have this code? It should be in a form_X.js file, and you should be calling hidecomment_sec(this) from a JS event on (I presume) elB.

-- hugh
 
Hi Hugh,
I've a file called form_1.js (com_fabrik/js) and calling this file with hidecomment_sec(this); from fab_cp1_line_tour___security_check (elB) with load and change event.
Cheers
 
Hi Hugh,
js is getting more difficult and I need your support;) I will upgrade my subscription and start a new post in professional.

Cheers,
Bianka
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top