maryanmendoza / jquery-ui-map

Automatically exported from code.google.com/p/jquery-ui-map
0 stars 0 forks source link

Possible bug in jquery-ui-map 3.0 rc "find" method. #66

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Method "find" didn't work properly for me when I tried to write my own
code based on "Google maps jQuery plugin 3.0-rc1 filter
by property" example. Here is my attempt to fix the problem:

find: function(ctx, options, callback) {
        var obj = this.get(ctx);

        options.value = $.isArray(options.value) ? options.value : [options.value];
        for ( var property in obj ) {
                // Correct search in marker properties. We are looking for options.property.
                if ( obj[property].hasOwnProperty(options.property) ) {
                        // We always need an array for inArray method.
                        obj[property][options.property] = $.isArray(obj[property][options.property]) ? obj[property][options.property] : [obj[property][options.property]];

                        var isFound = false;
                        for ( var value in options.value ) {
                                // the second argument must be an array.
                                if ( $.inArray(options.value[value], obj[property][options.property]) > -1 ) {
                                        isFound = true;
                                } else {
                                        if ( options.operator && options.operator === 'AND' ) {
                                                isFound = false;
                                                break;
                                        }
                                }
                        }
                        callback(obj[property], isFound);
                }
        }
        return this; 

Original issue reported on code.google.com by xyxyxyxy...@gmail.com on 25 Nov 2012 at 5:43