src/selectivity.js
function(elementOrEvent) {
        var el = elementOrEvent.target || elementOrEvent;
        while (el) {
            if (el.hasAttribute('data-item-id')) {
                break;
            }
            el = el.parentNode;
        }

        if (!el) {
            return null;
        }

        var id = el.getAttribute('data-item-id');

        // IDs can be either numbers or strings, but attribute values are always strings, so we
        // will have to find out whether the item ID ought to be a number or string ourselves.
        if (Selectivity.findById(this._data || [], id)) {
            return id;
        } else {
            var dropdown = this.dropdown;
            while (dropdown) {
                if (Selectivity.findNestedById(dropdown.results, id)) {
                    return id;
                }
                // FIXME: reference to submenu plugin doesn't belong in base
                dropdown = dropdown.submenu;
            }
            var number = parseInt(id, 10);
            return '' + number === id ? number : id;
        }
    }
function(elementOrEvent) {
        var el = elementOrEvent.target || elementOrEvent;
        while (el) {
            if (el.hasAttribute('data-item-id')) {
                break;
            }
            el = el.parentNode;
        }

        if (!el) {
            return null;
        }

        var id = el.getAttribute('data-item-id');

        // IDs can be either numbers or strings, but attribute values are always strings, so we
        // will have to find out whether the item ID ought to be a number or string ourselves.
        if (Selectivity.findById(this._data || [], id)) {
            return id;
        } else {
            var dropdown = this.dropdown;
            while (dropdown) {
                if (Selectivity.findNestedById(dropdown.results, id)) {
                    return id;
                }
                // FIXME: reference to submenu plugin doesn't belong in base
                dropdown = dropdown.submenu;
            }
            var number = parseInt(id, 10);
            return '' + number === id ? number : id;
        }
    }
function ( elementOrEvent ) { var el = elementOrEvent . target || elementOrEvent ; while ( el ) { if ( el . hasAttribute ( 'data-item-id' ) ) { break ; } el = el . parentNode ; } if ( ! el ) { return null ; } var id = el . getAttribute ( 'data-item-id' ) ; // IDs can be either numbers or strings, but attribute values are always strings, so we // will have to find out whether the item ID ought to be a number or string ourselves. if ( Selectivity . findById ( this . _data || [ ] , id ) ) { return id ; } else { var dropdown = this . dropdown ; while ( dropdown ) { if ( Selectivity . findNestedById ( dropdown . results , id ) ) { return id ; } // FIXME: reference to submenu plugin doesn't belong in base dropdown = dropdown . submenu ; } var number = parseInt ( id , 10 ) ; return '' + number === id ? number : id ; } }
Returns the item ID related to an element or event target.

@param elementOrEvent The DOM element or event to get the item ID for.

@return Item ID or null if no ID could be found.
Returns the item ID related to an element or event target .