0

I have created a button named "Freeze". I want to create a dynamic action that changes the name from "Freeze" to " "UnFreeze" on click. I have set the static id for the button as "Freeze_StaticID" and then created a dynamic action for the click event. Under True condition, I want to add a javascript query for the same. Can anyone please tell me the query I need to add for the same? I tried adding the code below but it didn't work.

$("#Freeze_StaticID").attr ('value', 'UNFREEZE')
3
  • well, $("#Freeze_StaticID").html ('UNFREEZE') will change the text, if that's what you're trying to do
    – Alon Eitan
    Commented Oct 28, 2020 at 6:58
  • There might be a simpler solution which is a bit more declarative. Instead of changing the button label, why don't you create 2 buttons ? One "Freeze" and one "Unfreeze". Your dynamic action can then show one and hide the other on click. Commented Oct 28, 2020 at 8:39
  • @KoenLostrie I had this idea in mind but am looking for an option where I don't need to create another button, also it would be very simplified if we could just add a js query to change the label, otherwise, I have the option of creating 2 buttons, hiding one. Commented Oct 28, 2020 at 10:25

2 Answers 2

1

It depends on the HTML implementation. When it's a <button> element, then it works like this: $('#Freeze_StaticID').text('UNFREEZE')

Btw: It's jQuery behind the scenes. You can toggle the browser's developer console (F12) and execute the appropriate getter and see what the result is for:

$('#Freeze_StaticID').text();
$('#Freeze_StaticID').attr ('value');

When undefined is returned, it's the wrong approach because it should return the current title of the button.

Details:

0

Just use the JavaScript API for Apex

apex.item("Freeze_StaticID").setValue("UNFREEZE");

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.