Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !6836

store typehead item value as a object not string

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/hefangshi/3.0.0-wip into 3.0.0-wip Feb 08, 2013
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: hefangshi

now the typehead control can only use string to build the list,we can't store more data in the items.

so i change the attr('data-value') to data('value') to get object value from the select, so we can extend the item object like this.

    var TypeHeadItem=function(item,value){
        this.item=item;
        this.value=value;
    };

    TypeHeadItem.prototype={
        toString: function() {
            return this.value;
        },
        toLowerCase:function(){
            return String.prototype.toLowerCase.apply(this.value);
        },
        indexOf:function(value){
            return String.prototype.indexOf.apply(this.value,arguments);
        },
        replace:function(){
            return String.prototype.replace.apply(this.value,arguments);
        }
    };

    TypeHeadItem.prototype.__defineGetter__('length',function(){return this.value.length;});

then we can get more information from the typehead selected item, so we don't need to use a cache to store the object which match to the key.It's useful when u have same keyword for different items.(although typehead is not desgined for this,but we use it)

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/hefangshi/3.0.0-wip