Skip to content
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

.selector property is removed #353

Open
geoffreyk opened this issue Aug 26, 2013 · 4 comments
Open

.selector property is removed #353

geoffreyk opened this issue Aug 26, 2013 · 4 comments

Comments

@geoffreyk
Copy link

http://jquery.com/upgrade-guide/1.9/#selector-property-on-jquery-objects

As of 1.9, the .selector property is gone.
Looks like it is still hanging around in in ajaxForm.
Unless I am reading this wrong, .selector needs to be dealt with.

$.fn.ajaxForm = function(options) {
options = options || {};
options.delegation = options.delegation && $.isFunction($.fn.on);

// in jQuery 1.3+ we can fix mistakes with the ready state
if (!options.delegation && this.length === 0) {
    var o = { s: this.selector, c: this.context };
    if (!$.isReady && o.s) {
        log('DOM not ready, queuing ajaxForm');
        $(function() {
            $(o.s,o.c).ajaxForm(options);
        });
        return this;
    }
    // is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
    log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
    return this;
}

if ( options.delegation ) {
    $(document)
        .off('submit.form-plugin', this.selector, doAjaxSubmit)
        .off('click.form-plugin', this.selector, captureSubmittingElement)
        .on('submit.form-plugin', this.selector, options, doAjaxSubmit)
        .on('click.form-plugin', this.selector, options, captureSubmittingElement);
    return this;
}

return this.ajaxFormUnbind()
    .bind('submit.form-plugin', options, doAjaxSubmit)
    .bind('click.form-plugin', options, captureSubmittingElement);

};

@ghost
Copy link

ghost commented Aug 30, 2013

Agreed this is a problem, but use of .selector is necessary for proper handling of ajaxForm's "delegation" option. If you ask me, the "delegation" option should be deprecated altogether and any code adding new <form> elements should be responsible for issuing the corresponding .ajaxForm(~) calls itself.

I'll put together a pull request for this later today.

@malsup
Copy link
Collaborator

malsup commented Sep 2, 2013

The selector property is not gone, it is deprecated.

@geoffreyk
Copy link
Author

ah, yes. Sorry about that. I picked this out when I was sweeping my code for .live().
Not really sure what the work around will be if/when it is actually removed.

@kevindb
Copy link
Contributor

kevindb commented Feb 21, 2017

It looks like jQuery 3 finally removed .selector. https://jquery.com/upgrade-guide/3.0/#breaking-change-deprecated-context-and-selector-properties-removed
Has anybody used the plugin with jQuery 3.x? Does it error?

I'm really not sure what this portion of the plugin code is doing, or how to refactor it. Help would definitely be appreciated!

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

No branches or pull requests

3 participants