spjs.dffs.dlgBox vs. browser alert

Forums Dynamic Forms for SharePoint spjs.dffs.dlgBox vs. browser alert

This topic contains 5 replies, has 2 voices, and was last updated by  Alexander Bautz 6 months ago.

  • Author
    Posts
  • #20168

    Bryan Waldrop
    Participant

    I love the style of your alert box spjs.dffs.dlgBox. However, my users who are used to closing standard browser alerts with the enter key noticed it replicated the spjs.dffs.dlgBox instead of closing. Is there keyboard equivalent to close the box?

    Also, there is no “bell alarm” with spjs.dffs.dlgBox. Is there a way to enable a sound with the prompt?

  • #20182

    Alexander Bautz
    Keymaster

    Hi,
    The reason for duplicating the alert most likely is due to the focus being on the trigger that opened the alert in the first place. Currently keyboard events (Enter or Esc) doesn’t work, but I’ll see what I can do about it.

    It is possible to play a sound when the alert pops up, but it’s a bit cumbersome because you cannot play the “system default” sound so you would have to use a “mp3” or “ogg” file and it won’t work in IE.

    Alexander

  • #20229

    Bryan Waldrop
    Participant

    Thank you sir! Apparently the ability to use enter is a big deal to these users as I heard from another group about it today. I have several “scripts” for them to read before entering information that are alert box driven. I thought I would ask if there was an easy fix before changing them all back to alert.

  • #20242

    Alexander Bautz
    Keymaster

    I’ve made this snippet and it seems to do the trick. Add it to your forms Custom JS:

    jQuery(document).on("keydown",function(event) {
        if(jQuery(".dffs_dlg_overlay").length > 0){
            if (event.which === 13) {
        		jQuery(".dffs_dlg_overlay:last").find(".spjs-dlg-btnOK").trigger("click");
            }
        	if (event.which === 27) {
        		jQuery(".dffs_dlg_overlay:last").find(".spjs-dlg-btnCancel").trigger("click");
            }
        }
    });

    I’ll run some more tests, but I appreciate your feedback on how it works in your setup.

    Alexander

  • #20329

    Bryan Waldrop
    Participant

    Thank you for this! The results of my testing are that it works wonderfully in my SP2013 environment with a small exception. I have a coded “copy to clipboard” button/function where the alert for it will not close with enter after running.
    Over in the SP 2010 environment, your snippet fires my “copy to clipboard” function every time enter is used to close any spjs.dffs.dlgbox. In SP2013 I can workaround by changing my “copy to clipboard” function back to a browser’alert’. But that did not work in SP 2010.

    
    
    //copytoclipboard
    function copyNotesToClip()
    		{
    			
                            var txtNotes = getFieldValue('Call_x0020_Notes');
    		        spjs.dffs.dlgBox ("Notes successfully copied to clipboard. Paste to system of record before resetting this form.");
    			if( window.clipboardData && window.clipboardData.setData ) {
    			   window.clipboardData.setData("Text", txtNotes);
    			}
    		}
    
    $(spjs.dffs.fields["Call_x0020_Notes"]).find('.ms-formbody').append("<button class='customBtnA' onclick='copyNotesToClip();return false'>Copy Notes to Clipboard</button>"); 
  • #20335

    Alexander Bautz
    Keymaster

    Not sure, but can you try changing “spjs.dffs.dlgBox” with “spjs.dffs.alert” like this:

    spjs.dffs.alert({"title":"This is the title","msg":"This is the message."});

    Try changing the custom button you have inserted like this (from <button> to <input type=’button’>):

    jQuery("#dffs_Call_x0020_Notes").find('.ms-formbody').append("<input type='button' class='customBtnA' onclick='copyNotesToClip();return false' value='Copy Notes to Clipboard'>");

    Alexander

    • This reply was modified 6 months ago by  Alexander Bautz. Reason: Fixed typo

You must be logged in to reply to this topic.