JQuery - Dangerous Challenge - Receive the parameter function
Guys,
This challenge is so dangerous to me. I developed a plugin for my company. It is as follows:
To call a plugin, simply enter the code below:
- $(this).validateAudience({module: 'specific', specific: 'dateAll["#id_name"]'});
In this plugin, the function model is thus:
- $.fn.validateAudience = function(settings) {
- if(settings) {
- try {
- //currying - techniques javascript.
- execute( add(settings));
- return true;
- } catch(error) {
- cancel(error.description);
- }
- } else {
- alert("Unable to call validateAudience. It's need specific parameter.");
- }
- };
And the function execute() is as follows:
- var execute = function(settings) {
- module[settings.module].apply( this, arguments);
- }
Where in function "module", is thus:
- var module = {
- specific: function(settings) {
- input[settings.specific].apply( this, arguments );
- }
Where the function "input", is thus:
- var input = {
- dateAll: function(parameter) {
- /* this is where I want the function receives the parameter */
- },
- }
Does anyone have any idea how to do that the function receives the parameter in dateAll informed from the first code on the screen, as below:
- $(this).validateAudience({module: 'specific', specific: 'dateAll["#id_name"]'});
Anyway, for those who want to visualize the complete contents of the plugin I created for my company as follows: http://forum.imasters.uol.com.br/index.php?/topic/410831-jquery-desafio-perigoso-receber-o-parametro-na-funcao/
Thanks,
Vinicius - Brazil.