Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

"data-remote" attribute query parameter support#250

Open
vuraldincer wants to merge 32 commits into
masterfrom
gh-pages
Open

"data-remote" attribute query parameter support#250
vuraldincer wants to merge 32 commits into
masterfrom
gh-pages

Conversation

@vuraldincer
Copy link
Copy Markdown

Some frameworks (ex: stripes FW) for receiving data-remote address parameters are a problem. It's supposed to parse the given parameters.

   if (!errors.length && $el.val() && $el.data('remote')) {
      this.defer($el, function () {
      var remoteUri = (function(uri) {
            if( -1 === uri.indexOf('?') ) return uri;
            return uri.substr( 0,uri.indexOf('?') );
      })( $el.data('remote') );         
      var qs = (function(uri) {
            var b = {};
            if( -1 === uri.indexOf('?') ) uri+='?';
            var a = uri.substr( uri.indexOf('?')+1 ).split('&');  
            if( "" === a || "" === a[0] ) return b;
            for (var i = 0; i < a.length; ++i)
            {
                var p=a[i].split('=', 2);
                if ( p.length === 1 && ""!==p[0] )
                    b[ p[0] ] = "";
                else
                    if( ""!==p[0] ) b[ p[0] ] = decodeURIComponent( p[1].replace(/\+/g, " "));
            }
            return b;                       
        })( $el.data('remote') );        
        var data = {};
        data[ $el.attr('name') ] = $el.val();
        $.extend( data, qs );                
        $.get( remoteUri, data)
          .fail(function (jqXHR, textStatus, error) { errors.push( getErrorMessage('remote') || error ) })
          .always(function () { deferred.resolve(errors)})
      })
    } else deferred.resolve(errors)

@1000hz 1000hz deployed to github-pages December 5, 2016 06:14 Active
@1000hz 1000hz deployed to github-pages December 5, 2016 17:19 Active
@1000hz 1000hz deployed to github-pages December 8, 2016 03:59 Active
@1000hz 1000hz deployed to github-pages January 6, 2017 02:02 Active
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants