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

Can .rules() method work on a collection? #841

Closed
brownieboy opened this issue Aug 7, 2013 · 3 comments
Closed

Can .rules() method work on a collection? #841

brownieboy opened this issue Aug 7, 2013 · 3 comments

Comments

@brownieboy
Copy link

I was trying to use the .rules() method to dynamically remove the rules from a jQuery collection of fields but it wouldn't work. I was selecting by class, like so:

$(".myClass").rules("remove");

where myClass was added to a number of input fields. For some reason though, it was only removing the rules from the first member of the collection returned. When I checked the source code for the .rules() method, I could see why: the method's first line is:

var element = this[0];

So, it's specifically coded to only process the first member of the calling jQuery collection. I'm getting around this by looping through my collection in my call, like so:

$(".myClass").each(function(index, element) {
    $(element).rules("remove");
});

But that's messy. Is there some reason that we can't have the .rules() method do this looping instead?

I don't mind taking a look at it.

@brownieboy brownieboy reopened this Aug 7, 2013
@brownieboy
Copy link
Author

Closed by mistake (butterfingers....)

@Indomitable
Copy link

The rules should work for each element selected by jquery. In my case it happened that the selection didn't return any elements and I got an error from rules method. At least check if this[0] !== undefined or this.length === 1.

@jzaefferer
Copy link
Collaborator

I'm sorry for the lack of activity on this issue. Instead of leaving it open any longer, I decided to close old issues without trying to address them, to longer give the false impression that it will get addressed eventually, especially after several years with no activity. It doesn't mean I'm abandoning the project, just that I'm unable to work through 200+ open issues with the little time I can afford to spend on this project.

To the reporter (or anyone else interested in this issue): If you're still affected by the same issue, please consider opening a new issue, with a testpage that demonstrates the issue with a current version of the plugin. Even better, make an attempt to fix the issue yourself, and improve the project by sending a pull request. This may seem daunting at first, but you'll likely learn some useful skills that you can apply elsewhere as well. And you can help keep this project alive. We've documented how to do these things, too. A patch is worth a thousand issues!

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

No branches or pull requests

3 participants