returning false in HTML entities with checkboxes

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

returning false in HTML entities with checkboxes

#1

Postby Segi » Tue Jul 18, 2017 5:19 pm

I have a table column that is a checkbox.

In HTML entities->editor input, I have this code for the jQuery change event:

Code: Select all

if ($(this).prop('checked')==false) {
     return;	
}

var result = confirm("Are you sure you want to delete this user account ?");

$(this).prop('checked',result);

if (result==false) {
     $(this).prop('checked',result);

     return result;
}
This code doesn't show any dialog when the checkbox is already checked and you are unchecking it.

If it isn't checked and you are checking it, the confirm() dialog is shown.

It used to be where you didn't need to manually check or uncheck the checkbox.

By returning false in HTML entities, the checkbox would remain unchecked if you had checked it but clicked on cancel in confirm() which results in return false;

This doesn't appear to be the case any more so I've resorted to manually unchecking it

While stepping through this code in the Chrome Developer console, if I put a breakpoint on the line return result; after clicking on cancel in the confirm() dialog, the checkbox does get unchecked correctly.

It seems that returning false doesn't stop execution of the script because after the return statement, it appears as though there's jQuery related code that is being executed. After that jQuery code has finished executing, the checkbox is checked again.

Is this a bug with HTML entities ? I have 2 different instances of eBase 5.2.1 that have this same issue

There is no server side event tied to this field that would modify its checked state.

Update: I found out what the problem was but it doesn't make any sense to me why its causing a problem. Immediate Validation was checked but as I mentioned before, there was no server side script being executed but regardless, the fact that Immediate Validation was checked was causing this behavior. After unchecking it, the problem went away.

This is still an issue though where if you want to use HTML entities, you cannot use immediate validation with a server side script because it will execute the server side script immediately and bypasses the HTML entities events entirely. I realize that you can use executeFunction() to run a server side function but this is not a good approach in my opinion.

I hope that this will be fixed in the next version of eBase so that even if immediate validation is checked for a control, the HTML entity events gets executed first, if there are any.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Wed Jul 19, 2017 11:34 am

I've raised a bug for this. The client side event should run first and it should be possible to stop the server event by returning false in the client event.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#3

Postby Segi » Wed Jul 19, 2017 2:43 pm

great thanks!
0 x


Who is online

Users browsing this forum: No registered users and 6 guests