Changing the functionality of the inline edit.

When you click away from the inline edit without clicking the checkmark, you get a javascript popup that says:

You have clicked away from the field you were editing without saving it. Click ok if you’re happy to lose your change, or cancel if you would like to continue editing “THE FIELD”?

Is it possible to make the field save instead when clicking away?

Secondary, it would also be benefital to my application to be able to tab to the next field saving the field upon each subsequent tab.

Is this possible?

This is where the code is:

include/InlineEditing/inlineEditing.js:316:                var r = confirm(SUGAR.language.translate('app_strings', 'LBL_CONFIRM_CANCEL_INLINE_EDITING') + ' ' + message_field);

So you can try adapting it to your needs by customizing.

1 Like

Cool. I was able to add the functionality I wanted. If anyone else is interested here is what i did:

To save and move to the next tab (when pressing the tab key), I added this to the bottom of the validateFormAndSave function


$(document).keydown(function(e) {
        if (e.which == 9 && !e.shiftKey) {
            $inlineEdits = $('div.inlineEdit');          
            e.preventDefault();
            $("#inlineEditSaveButton").click();
            $tabNext = false;
            $inlineEdits.each(function (index, value)
            {
                if($tabNext == true) { $(value).dblclick(); }
                if($(value).hasClass('inlineEditActive')) { $tabNext = true; }
            });
        }
    });

To remove alert and save when clicking out I change the $(document).on(‘click’, function (e)


if (alertFlag) {
              e.preventDefault();
              $("#inlineEditSaveButton").click();
            } else {

Hey thanks for posting that code. Did you get it working under the “custom” directory? Just trying to make sure it’s upgrade-safe.

Another question: is that “save and move focus” code something you think should be added to SuiteCRM?

No its not working under the custom directory. I’m not sure what to do there. Also the code seems to work ok in firefox, but is copying the previous field data to the next field when tabbing in chrome and edge. Going to look into that this week.

As far as using it in SuiteCRM, im all for it. It helps me quickly enter data in my specific data entry application i need it for. Not sure how helpful itd be outside those bounds.

I want to share the following in case somebody need to customize this file. Following your sample I found I can display custom messages based on the module the function is called from.

In this case I’m presenting a message box when inline edit occurs on the Opportunities module:

function validateFormAndSave(field,id,module,type){

    $("#inlineEditSaveButton").on('click', function () {
        var valid_form = check_form("EditView");
        if(valid_form){
	                // HERE MY CODE to identify the module I want to show the message
			if (module == "Opportunities"){				
			     	handleSave(field, id, module, type)
				clickListenerActive = false;
				$('[field="'+field+'"]').addClass('fix-inlineEdit-textarea');

	// HERE we user the ALERT BOX to present the message on the Opportunities module only
	alert("Hello! I am an alert box!!");
			}else{
				handleSave(field, id, module, type)
				clickListenerActive = false;
				$('[field="'+field+'"]').addClass('fix-inlineEdit-textarea');
			};
        }else{
            $('[field="'+field+'"]').removeClass('fix-inlineEdit-textarea');
            return false
        };
    });
    // also want to save on enter/return being pressed
    $(document).keypress(function(e) {

        if (e.which == 13 && !e.shiftKey) {
            e.preventDefault();
            $("#inlineEditSaveButton").click();
        }
    });
}

Thanks,

1 Like

Does anyone find a way to delete this alert in the custom folder ? If I delete the code in the original js file it work, but its not really good to edit original file…

You can delete this by commenting this in /include/InlineEditing/InlineEditing.js :

            /*if (user_value != output_value_compare) {
                message_field = message_field != 'undefined' ? message_field : '';
                var r = confirm(SUGAR.language.translate('app_strings', 'LBL_CONFIRM_CANCEL_INLINE_EDITING') + ' ' + message_field);
                if (r == true) {
                    var output = setValueClose(output_value);
                    clickListenerActive = false;
                } else {
                    $("#" + field).focus();
                    e.preventDefault();
                }
            } else {
                // user hasn't changed value so can close field without warning them first
                var output = date_compare ? setValueClose(user_value) : setValueClose(output_value);
                clickListenerActive = false;
            }*/

Super anoying when you select the field value with the mouse (like a ctrl A) and the click out event is outside the field, you get that alert… Terrible for the workflow ahah.

Looking for an “upgrade-safe” method !