diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index 3fc2811c9..4f4b5c07a 100644 --- a/src/definitions/behaviors/api.js +++ b/src/definitions/behaviors/api.js @@ -162,9 +162,9 @@ $.api = $.fn.api = function(parameters) { // exit conditions reached, missing url parameters if( !url ) { - if($module.is('form')) { - module.debug('No url or action specified, defaulting to form action'); - url = $module.attr('action'); + if( module.is.form() ) { + url = $module.attr('action') || ''; + module.debug('No url or action specified, defaulting to form action', url); } else { module.error(error.missingURL, settings.action); @@ -212,6 +212,12 @@ $.api = $.fn.api = function(parameters) { disabled: function() { return ($module.filter(settings.filter).length > 0); }, + form: function() { + return $module.is('form'); + }, + input: function() { + return $module.is('input'); + }, loading: function() { return (module.request && module.request.state() == 'pending'); } @@ -508,10 +514,10 @@ $.api = $.fn.api = function(parameters) { data = {} ; if( !$.isWindow(element) ) { - if( $module.is('input') ) { + if( module.is.input() ) { data.value = $module.val(); } - else if( $module.is('form') ) { + else if( !module.is.form() ) { } else { @@ -570,7 +576,7 @@ $.api = $.fn.api = function(parameters) { url = settings.api[action]; module.debug('Found template url', url); } - else { + else if( !module.is.form() ) { module.error(error.missingAction, settings.action, settings.api); } }