Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert jquery inArray to extjs equivalent

Tags:

jquery

extjs

does extjs contain method equivalent to inArray? i checked the API but found nothing!

here is the jquery snippet that need urgent conversion:

if ($.inArray(checkbox.inputValue, values) >= 0)

where values is array.

thanks,

like image 304
Jawad Al Shaikh Avatar asked Feb 21 '26 12:02

Jawad Al Shaikh


2 Answers

Ext JS has Array.indexOf, which does exactly the same thing that the unfortunately-named jQuery.inArray does:

if(values.indexOf(yourValue) !== -1)
like image 140
John Flatness Avatar answered Feb 24 '26 07:02

John Flatness


Ext.js does not appear to have this function. See http://docs.sencha.com/core/manual/

You can monkey patch this in if you like:

Ext.inArray = function(value, collection) {
    return collection.indexOf(value) !== -1;
};
like image 40
Jacob Relkin Avatar answered Feb 24 '26 05:02

Jacob Relkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!