This topic is locked
[SOLVED]

 Hide and Show Button on List Page

1/7/2018 8:56:27 AM
PHPRunner General questions
W
wedi author

Hello
I want to show and hide a custom Button (closeBewertung) on List Page Header (not for every record) depending on successfull ajax save.



$.ajax({

type: "POST",

url: "dbo_v_praktikumBewertung_edit.php?submit=1",

data: data

}).done(function(jsondata) {

var decoded = $('<div/>').html(jsondata).text();

response = jQuery.parseJSON( decoded );
if (response["success"]==true) {

$("#closeBewertung").show();

} else {

$("#closeBewertung").hide();

}

});


The jQuery works fine and with $("#closeBewertung").show() i want to show the button. But that doesn't work.
What works is the command $("#closeBewertung").hide() when i create an error with jQuery.
Is .show() not the right command to show the Button?
Thanks for your help.

wedi

admin 1/8/2018

You need to find the actual ID of that button and use it instead of "closeBewertung" in $("#closeBewertung").show();

W
wedi author 1/8/2018

Hello,
thanks for your help. But which id should i use?
Here is the code in HTML-Mode how the Button is defined (List page):



{BEGIN closeBewertung}

<A class="rnr-button btn btn-closeBewertung" id="closeBewertung" href="#" typeid="ib">

Bewertung abschließen

</A>

{END closeBewertung}


And i found out another behavior:

Once i "show" the Button in "Before display" with $xt->assign("closeBewertung", true) and then "hide" the button with $("#closeBewertung").hide() as first command (outside a function) in "Javascript onload", the command $("#closeBewertung").show() works fine!?
But the unbeautiful effect of this workaround is that the user can see the button for a short time when the page is reloaded.
Do you have an explenation for this behavior.
Thanks

wedi

admin 1/10/2018

To find button ID proceed to that page in web browser, right click on your button, choose 'Inspect' and see the ID as it is shown on the screenshot. As you can see correct ID is saveButton1

W
wedi author 1/11/2018

Hello Sergey,
Thanks for your reply, but it don't works. It only works with the workaround in my previous description.
But your tip inspired me to check the sourcecode of the html page and i found out the following difference:
When i don't "show" the Button in "Before display" with $xt->assign("btn_closeBewertung", true) there is no html-code for the button in the source:



<DIV class="bottom-margin col-md-6" style="width: 54.8%; height: 86px;" data-container="add_delete" data-pageid="1" >

<P>



<SPAN data-brick="recordcontrol" data-pageid="1" >





<BUTTON class="btn btn-primary" type="button" name="saveall_edited1" id="saveall_edited1" style="display:none;" >

Alle Datensätze speichern

</BUTTON>





<BUTTON class="btn btn-default" type="button" name="revertall_edited1" id="revertall_edited1" style="display:none;" >

Abbruch

</BUTTON>



</SPAN>



</P>

</DIV>


When i use my workaround: $xt->assign("btn_closeBewertung", true) in "Before display" and $('#closeBewertung').hide() as command in "Javascript onload" the button is defined in the html-source:



<DIV class="bottom-margin col-md-6" style="width: 54.8%; height: 86px;" data-container="add_delete" data-pageid="1" >

<P>



<SPAN data-brick="recordcontrol" data-pageid="1" >



<A class="rnr-button btn btn-closeBewertung" id="closeBewertung" href="#" typeid="ib">

Bewertung abschließen

</A>





<BUTTON class="btn btn-primary" type="button" name="saveall_edited1" id="saveall_edited1" style="display:none;" >

Alle Datensätze speichern

</BUTTON>





<BUTTON class="btn btn-default" type="button" name="revertall_edited1" id="revertall_edited1" style="display:none;" >

Abbruch

</BUTTON>



</SPAN>



</P>

</DIV>


But i wonder that the tag of this button (inserted with rightclick in design-mode) is not <BUTTON> but <A>. But also when i change the tag, the button wasn't show.
Here again the buttons as defined in phprunner - HTML Mode



<DIV class="bottom-margin col-md-6" style="width: 54.8%; height: 86px;" data-container="add_delete" data-pageid="{$pageid}" {$add_delete_chiddenattr}>

<P>

{BEGIN record_controls_block}

<SPAN data-brick="recordcontrol" data-pageid="{$pageid}" {$recordcontrol_hiddenattr}>

{BEGIN btn_closeBewertung}

<A class="rnr-button btn btn-closeBewertung" id="closeBewertung" href="#" typeid="ib">

Bewertung abschließen

</A>

{END btn_closeBewertung}

{BEGIN saveall_link}

<BUTTON class="btn btn-primary" type="button" {$savealllink_attrs} {$savealllink_span}>

Alle Datensätze speichern

</BUTTON>

{END saveall_link}

{BEGIN cancelall_link}

<BUTTON class="btn btn-default" type="button" {$cancelalllink_attrs} {$cancelalllink_span}>

Abbruch

</BUTTON>

{END cancelall_link}

</SPAN>

{END record_controls_block}

</P>

</DIV>



Do you have an other idea?
thanks

wedi

admin 1/11/2018

I'm struggling to understand what is the issue here. If you know your button/link ID you can just show and hide it via Javascript code.

W
wedi author 1/11/2018

Hello Sergey,
with your previous tip to identify the button id and some experimental, i found the solution for my problem:
The Problem was my manual added block
{BEGIN closeBewertung}

...

{END closeBewertung}
because i thought that was necessary to show and hide the button in "Javascript onload". In "Before display" i checked whether to show the button and if not, i use $xt->assign("closeBewertung", false) to make the button unvisible. But with this command, i remove the code snippet of the button from the HTML-code and so i couldn't show/hide the button in javascript because there was no button id which i could adress.
So i've deleted the button from Design Mode and insert a new button by "rightclick -> insert -> button" and modifyed the snippet with style="display:none;"



<A class="rnr-button btn btn-closeBewertung" id="Bewertung_beenden2" href="#" typeid="ib" style="display:none;">

Bewertung beenden

</A>


And: i moved the whole logic to show or hide the button to "Javascript onload" and - it works fine!
Many thanks!!

Dieter