[jQuery] remove objects from set
Hi!
Using hints from this group, I create set of invalid fields this way:
jQuery.fn.push = function( selector_or_nodes ) {
// Given a selector or a jQuery object, append all of the
nodes to
// the current jQuery object.
var nodes = (typeof a == 'string') ?
$( selector_or_nodes ) : selector_or_nodes;
var node_count = nodes.length;
for( var i = 0; i < node_count; i++ ) {
this[ this.length++ ] = nodes[ i ]
};
};
$.extend({
validation: {
invalidFields: $([]),
addInvalidField: function(field) {
this.invalidFields.pushIf($(field));
}
}
});
// code here...
$.addInvalidField($('#myid1'));
// more code here...
$.addInvalidField($('#myid2'));
How to remove object from $.validation.invalidFields?
I'm trying to do it like this:
jQuery.fn.removeIf = function(selector_or_nodes) {
// Given a selector or a jQuery object, removes all of the
nodes from
// the current jQuery object.
var nodes = (typeof a == 'string') ?
$(selector_or_nodes) : selector_or_nodes;
for (var i = 0; i<this.length; i++) {
for (var j=0; j<nodes.length;j++) {
if (this[i]==nodes[j]) {
// REMOVE THIS ELEMENT HERE
}
}
}
};
I managed to determine if object exist in that set,
but how to remove it?
--
regards,
takeshin