UnitApi /
js
| 1 | /** |
||
| 2 | * Rest |
||
| 3 | * formToObject |
||
| 4 | */ |
||
| 5 | var RestForm = function (separator, error, success) { |
||
| 6 | |||
| 7 | this.cfg = {}; |
||
| 8 | this.cfg.separator = separator; |
||
| 9 | // this.cfg.event = "submit"; |
||
| 10 | |||
| 11 | // var elmnt = el.first(); |
||
| 12 | |||
| 13 | var self = this; |
||
| 14 | |||
| 15 | this.submit = function (cfg) { |
||
| 16 | if (typeof cfg === 'undefined') { |
||
| 17 | cfg = {}; |
||
| 18 | } |
||
| 19 | |||
| 20 | cfg.event = "submit"; |
||
| 21 | // cfg.target = "form"; |
||
| 22 | |||
| 23 | |||
| 24 | if (typeof cfg.separator === 'undefined') { |
||
| 25 | cfg.separator = self.cfg.separator; |
||
| 26 | } |
||
| 27 | |||
| 28 | cfg.element = new E(cfg.separator); |
||
|
0 ignored issues
–
show
|
|||
| 29 | |||
| 30 | // config.event = cfg.event; |
||
| 31 | // config.target = cfg.event; |
||
| 32 | cfg.element.all('', function (forms) { |
||
| 33 | |||
| 34 | var rest_form = new Rest(cfg.url, '?', error, success); |
||
|
0 ignored issues
–
show
The variable
Rest seems to be never declared. If this is a global, consider adding a /** global: Rest */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 35 | |||
| 36 | // var forms = element.getElementsByTagName('form'); |
||
| 37 | // var forms = element.getElementsByTagName('form'); |
||
| 38 | |||
| 39 | for (var i = 0; i < forms.length; i++) { |
||
| 40 | |||
| 41 | var form = forms[i]; |
||
| 42 | //formEvent(forms[i], rest_form, error, success); |
||
| 43 | form.addEventListener(config.event, function (event) { |
||
|
0 ignored issues
–
show
The variable
config seems to be never declared. If this is a global, consider adding a /** global: config */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 44 | console.log(this); |
||
|
0 ignored issues
–
show
|
|||
| 45 | |||
| 46 | var data = formToObject(this); |
||
| 47 | var method = data.method; |
||
| 48 | delete data.method; |
||
| 49 | delete data.submit; |
||
| 50 | |||
| 51 | console.log(method); |
||
| 52 | |||
| 53 | rest_form.byMethod(method, data); |
||
| 54 | console.log(data); |
||
| 55 | |||
| 56 | event.preventDefault(); |
||
| 57 | }); |
||
| 58 | } |
||
| 59 | }); |
||
| 60 | // cfg.url; |
||
| 61 | // cfg.method; |
||
| 62 | } |
||
| 63 | |||
| 64 | } |
||
| 65 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.