New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement to toQueryString #2239

ibolmo opened this Issue Jan 19, 2012 · 0 comments


None yet
1 participant
Copy link

ibolmo commented Jan 19, 2012

I found this function in toQueryString. I'd like to use the anonymous function independently so that I can convert a single input/select/textarea element into a query string. Could toQueryString be changed so that toQueryString on a input/select/textarea executes the logic in the inner anonymous function, while in the form case, it iterates over the child input/select/textarea as it does now, calling the same function for each?

this.getElements('input, select, textarea').each(function(el){
    var type = el.type;
    if (! || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return;

    var value = (el.get('tag') == 'select') ? el.getSelected().map(function(opt){
        // IE
    }) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value');

        if (typeof val != 'undefined') queryString.push(encodeURIComponent( + '=' + encodeURIComponent(val));
return queryString.join('&');

@ibolmo ibolmo closed this Mar 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment