Description - son-salesteck/modalFormify GitHub Wiki
Create jquery plugin for creating or open a modal form and insert revelant form element and a submit handler through ajax. The plugin must : Provide plugin debugging Provide Public Access to Default Plugin Settings Provide Callback Capabilities Provide Public Access to Secondary Functions as Applicable Keep Private Functions Private Give Full Control of Elements Those information can be found on jquery.
The purpose of this plugin is to create form programatically through object and function. When form is submited, apply jqueryValidation Plugin.
Also the plugin must implement bootstrap modal.
- download or use CDN dependancy
- jquery 3.5.<
- jqueryValidation
- bootstrap 4.<
$(_selector).modalFormify(options);
Provide Public Access to Default Plugin Settings
example : // Plugin definition.
$.fn.modalFormify= function( options ) {
// Extend our default options with those provided.
// Note that the first argument to extend is an empty
// object – this is to keep from overriding our "defaults" object.
var opts = $.extend( {}, $.fn.modalFormify.defaults, options );
// Our plugin implementation code goes here.
};
// Plugin defaults – added as a property on our plugin function.
var default = $.fn.modalFormify.defaults = { option : {}, fieldOption : {} };
Determine the default object property and value for the use of our plugin
example :
var pluginDefOption = default.option = { // file path to the ajax url ajax: "/path/to/ajax-api" // or object "ajax": { "url": "data.json", "type": "POST", "data": function ( d ) { return $.extend( {}, d, { "extra_search": $('#extra').val() }); } } };