Hide Field on Load

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Aleks
Posts: 6
Joined: 2017-03-12 09:17

Hide Field on Load

Post by Aleks » 2017-12-30 22:15

Hi Sirs,

Im little bit stuck on a smaller issue while trying to get this to work.

I have found this code on the forum and created the tablename-dv.js in hooks folder

Code: Select all

jQuery(function(){
jQuery('#einschreibgebuehr_auswahl').click(function(){
if(jQuery(this).prop('checked')){
/* hide some stuff */
jQuery('#einschreibgebuehr').show();
}else{
/* show some stuff */
jQuery('#einschreibgebuehr').hide();
}
});
});
When i load the page the field is visible until i check and uncheck it - that works fine but i would like to make it only visible when the field is checked.

think i am missing something small...

thx for any kind of help

regards

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-02 13:29

I think it will work if you put the following code after the IF clause:

Code: Select all

jQuery('#einschreibgebuehr_auswahl').change();
in order to trigger the change event for the field.

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-02 16:17

I mean... add the line above BEFORE the last row.

New code would be:

Code: Select all

jQuery(function(){
	jQuery('#einschreibgebuehr_auswahl').click(function(){
		if(jQuery(this).prop('checked')){
			/* hide some stuff */
			jQuery('#einschreibgebuehr').show();
		}else{
			/* show some stuff */
			jQuery('#einschreibgebuehr').hide();
		}
	});
	jQuery('#einschreibgebuehr_auswahl').change();
});

Aleks
Posts: 6
Joined: 2017-03-12 09:17

Re: Hide Field on Load

Post by Aleks » 2018-01-03 16:23

Hi, thx for your suggestion

but it doesnt change the load behaviour of the field that,

it is still visible on load
until i check it once and uncheck it again - then it becomes unvisible...

it should appear on check ...

i am not sure if that is the right way i am trying this to get to work...

regards

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-03 19:09

I think the code below will work the way you want:

Code: Select all

jQuery('#einschreibgebuehr_auswahl').prop('checked', true);

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-03 19:10

You can also try with:

Code: Select all

jQuery('#einschreibgebuehr_auswahl').prop('checked', false);
that will make it unchecked by default.

Aleks
Posts: 6
Joined: 2017-03-12 09:17

Re: Hide Field on Load

Post by Aleks » 2018-01-03 20:38

the field is not checked by the default... this is fine...

the issue is that the field that should be hidden depending on the checkbox is not hidden on init like i am expecting...

here is a short vid of what is happening...

ISSUE_VID

regards

Aleks

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-04 10:59

I am just starting to learn this jQuery thing but, after some tests, I think the code below can work for you.

Note that I am forcing it, on start, to:
a) uncheck the checkbox
b) hide the field

Take a look and tell me something.

Code: Select all

jQuery(function(){
	jQuery('#einschreibgebuehr_auswahl').click(function(){
		if(jQuery(this).prop('checked')){
			/* hide some stuff */
			jQuery('#einschreibgebuehr').show();
		}else{
			/* show some stuff */
			jQuery('#einschreibgebuehr').hide();
		}
	});
	jQuery('#einschreibgebuehr_auswahl').prop('checked', false);
	jQuery('#einschreibgebuehr').hide();
});

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-04 11:07

I just coded the sample below in order to help you on it:

https://jsfiddle.net/uu9xmvz1/

I hope it can help you.

Aleks
Posts: 6
Joined: 2017-03-12 09:17

Re: Hide Field on Load

Post by Aleks » 2018-01-04 15:40

Thx a lot for your effort but it is still showing wrong on the created page...

your fiddle is working like expected but i am not able to get it to work on the page... it seams that the created page is not loading complete or the jquery is only starting to work when its clicked...

regards...

Aleks
Posts: 6
Joined: 2017-03-12 09:17

Re: Hide Field on Load

Post by Aleks » 2018-01-04 18:17

Got it,

thx for pointing me in the right way...

if someone looking for something similar here is my snippet

Code: Select all

jQuery(document).ready(function($){

$('#field_to_hide').hide();
$('label[for="label_of_field"]').hide();

    $('#checkbox_to_be_monitored').change(function(){
        if(this.checked)
            $('#field_to_hide').show();
        else
            $('#field_to_hide').hide();

    });
});

User avatar
Celson Aquino
Posts: 27
Joined: 2017-08-26 15:40
Location: Salvador, Bahia - Brazil

Re: Hide Field on Load

Post by Celson Aquino » 2018-01-04 20:36

Great!

Post Reply