jquery popup as confirmation
You say..1) Add Panel to page. Where can I find the Panel component ?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
You say..1) Add Panel to page. Where can I find the Panel component ?
Sorry, the Panel has been renamed to HTML component.
That worked.
Any suggestions on how I can make this reusable code to be used throughout my app. I don't what to keep adding HTML throughout my app. It would be ideal for me to use this instead of the 'alert' dialog.
You can try to create Custom Component from this panel and JS-code.
Can you please provide an example of this.
Thank you.
Sorry, don't have code sample. It should be coded by you.
Of course, it will be coded by me, but you surely must have some example. I am sure the entire community would appreciate your help.
Can you not help out a newbee ?
Hello, as asked above, here is code of dialog custom component.
Use it as body of HTML component.
pre
<div data-role="popup" data-dismissible="false" data-overlay-theme="a" data-theme="c" style="max-width:400px;" id="myDialog" class="ui-corner-all">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1 class="dlg_caption"> </h1>
</div>
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
<h3 class="ui-title"> </h3>
<p class="dlg_text"> </p>
<a href="#" data-role="button" class="okButton" data-inline="true" data-theme="c">OK</a>
<a href="#" class="noButton" data-role="button" data-inline="true" data-transition="flow" data-theme="b">NO</a>
<a href="#" class="cancelButton" data-role="button" data-inline="true" data-transition="flow" data-theme="b">Cancel</a>
</div>
</div>
<script>
function MessageDialog( caption, title, text, options ){
function closePopup( next ){
return function( event ){
next.apply( this, arguments );
$( '#myDialog' ).popup( "close" );
}
}
var $dlg = $( '#myDialog' );
options = $.extend({}, {
onOK: closePopup( $.noop ),
onNO: null,
onCancel: null
}, options)
$dlg.find( '.cancelButton' ).toggle( $.isFunction(options.onCancel) );
$dlg.find( '.noButton' ).toggle( $.isFunction(options.onNO) );
$dlg.find( '.okButton' ).off('vclick').on({ vclick: closePopup( options.onOK )});
$dlg.find( '.noButton' ).off('vclick').on({ vclick: closePopup( options.onNO ) });
$dlg.find( '.cancelButton' ).off('vclick').on({ vclick: closePopup( options.onCancel ) });
$dlg.find( '.dlg_caption' ).text( caption '' );
$dlg.find( '.ui-title' ).text( title '' );
$dlg.find( '.dlg_text' ).text( text || '' );
$dlg.popup( "open" );
}
</script>
/pre
And create custom component.
After this:
ul
liYou can create simple alert as:
preMessageDialog( 'MyAppName', 'Alert Text' );/pre/li
liAlert with additional text:
preMessageDialog( 'MyAppName', 'Alert Bold Text', 'Additional text' );/pre/li
liDialog with OK/NO buttons:
preMessageDialog( 'MyAppName', 'Alert Text', false, {
onOK: function() { /* useful code / },
onNO: function() { / useful code / }
} );/pre/li
liDialog with OK/Cancel buttons:
preMessageDialog( 'MyAppName', 'Alert Text', false, {
onOK: function() { / useful code / },
onCancel: function() { / useful code / }
} );/pre/li
liOr dialog with OK/NO/Cancel buttons:
preMessageDialog( 'MyAppName', 'Alert Text', false, {
onOK: function() { / useful code / },
onNO: function() { / useful code / },
onCancel: function() { / useful code */ }
} );/pre/li
Of Course you can replace 'MyAppName' with constant which defined somewhere else.
And there is no need to add code for closing popup. Every action is wrapped by code for closing popup./ul
LOVE THIS! Thank you!
For some reason though, my caption just says my title text. Can't figure it out. Any thoughts?
Hello! Please clarify what title text? Is it bound with code above?