Ajax Buttons on forms stop working

I’m using the new SC 8.1 ajax buttons on forms but they seem to be very unreliable.

I’ve found two scenarios in which ajax buttons completely stop working: nothing happens when I press them, not even the spinner.

To reproduce, add an ajax button to a form with just this command in it

sc_ajax_message ("Message", "Title", "timeout=0");

Check “Show in the inserting mode”.

Scenario 1 [EDIT - this was not reported correctly - see my next post]

Form with an ajax button is opened in insert mode by a different app where the following code is executed:

sc_apl_conf("form_with_ajax_button",.., "add");  
sc_redir("form_with_ajax_button");

Note that the Ajax button work if the form is opened in insertion mode without using sc_apl_conf(); e.g. via sql “where id=-1”.

Scenario 2

Form with an ajax button has one of its field label set to [label_text] and, during OnLoad, [label_text] is set to:

[label_text] = 'Some "double quotes" in a label'; 

Note that the Ajax button works if [label_text] is set to:

[label_text] = "Some 'single quotes' in a label";

and it works even if ‘Some “double quotes” in a label’ is hardcoded (without the single quotes) in the label setting of the field.

So the problem seems to be with double quotes inside the label but only if the label is set via a [variable].

In order to find out exactly what is going wrong you have to see the generated code.
I suspect you found a bug.

Did you try:
$temp=‘Some “double quotes” in a label’;
[label_text]=$temp;

Just to circumvent it…

@rr I hope NetMake will look into the generated code.
It’s very hard just to try and isolate the specific scenarios in which the issues occur.

On this topic I just noticed that the way I reported Scenario 1 in my original post was wrong.

Scenario 1 (ignore Scenario 1 in the my original post)

Form with an ajax button is opened in insert mode by a different app where the following code is executed:

sc_apl_conf(form_with_ajax_button, "start", "new");
sc_apl_conf(form_with_ajax_button, "field_display_off", "add"); // <-- THIS IS THE LINE THAT BREAKS THE AJAX BUTTON IN THE FORM form_with_ajax_button 
sc_redir(form_with_ajax_button);

To avoid the issue I’ve just deleted the sc_apl_conf(form_with_ajax_button, “field_display_off”, “add”) line and I disabled that button directly in the form_with_ajax_button OnLoad event:

sc_btn_display(“new”,“off”);

This is not the first time that I noticed that not having standard SC buttons on forms (e.g. by removing them in the toolbar) breaks my code even if I dont’ see any clear relation between my code and the SC standard buttons I remove.
While hiding them with sc_btn_display(“button”,“off”) is much safer.

[QUOTE=rr;40917]In order to find out exactly what is going wrong you have to see the generated code.
I suspect you found a bug.

Did you try:
$temp=‘Some “double quotes” in a label’;
[label_text]=$temp;

Just to circumvent it…[/QUOTE]

I don’t remember if I tried that.
Since the way I reported it was a simplification and I actually needed to use html <a href=“url”> tags in the label, I just used single quotes (’) to delimit the tags attributes (e.g. <a href='url>)