From 5f9a1ab7152b97acf35157ef43a370440b550889 Mon Sep 17 00:00:00 2001 From: jlukic Date: Sat, 28 Feb 2015 12:13:44 -0500 Subject: [PATCH] API no longer produces 'no action specified' error when defaulting to form action --- src/definitions/behaviors/api.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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); } }