SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    725
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Question jQuery: Calling variable

    Hi

    I am using jquery UI autocomplete in one of my website. What I was looking for is if I could call a variable from the "ui.autocomplete" function's options array (which is at line #21) to "ui.menu" function (line #459)?


    For example, I add an extra variable "myClass":

    Code:
    $.widget( "ui.autocomplete", {
    	options: {
    		myClass: 'highlight',
    		appendTo: "body",
    		autoFocus: false,
    		delay: 300,
    		minLength: 1,
    		position: {
    			my: "left top",
    			at: "left bottom",
    			collision: "none"
    		},
    		source: null
    	},
    and I should be able to call that variable somewhere under the "ui.menu" function, like this:

    Code:
    $.widget("ui.menu", {
    	_create: function() {
    		var self = this;
    		this.element
    			.addClass("ui-menu ui-widget ui-widget-content ui-corner-all " + parent.options.myClass)
    			.attr({
    				role: "listbox",
    				"aria-activedescendant": "ui-active-menuitem"
    			})

    I tried doing this using the parent.options.myClass syntax but it did not help. Can someone please tell me how to achieve this?

    PFA attached .js file.


    Thanks
    Attached Files Attached Files

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I'm not really experienced in the jQuery UI area but i did a quick search and came up with this http://stackoverflow.com/questions/7...-event-handler
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •