Make WordPress Core

Opened 15 years ago

Closed 10 years ago

#18518 closed defect (bug) (wontfix)

suggest.js: don't store the URL in the options object

Reported by: scribu Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords:
Cc: Focuses: javascript

Description

...because it prevents re-using the same instance for different URLs:

var suggest_args = {
	multiple     : true,
	delimiter    : ',',
	resultsClass : 'qc-suggest-results',
	selectClass  : 'qc-suggest-over',
	matchClass   : 'qc-suggest-match',
};

$( '#ticket-assign input' ).suggest( QC_L10N.ajaxurl + '?action=qc-user-search', suggest_args );

$( '#ticket-tags input' ).suggest( QC_L10N.ajaxurl + '?action=ajax-tag-search&tax=post_tag', suggest_args );

With the above code, both inputs will look for items in the same URL: the second one.

Attached patch fixes this.

Attachments (1)

18518.diff (1.4 KB ) - added by scribu 15 years ago.

Download all attachments as: .zip

Change History (8)

@scribu
15 years ago

#1 @scribu
15 years ago

  • Summary Don't store the URL in the options objectsuggest.js: don't store the URL in the options object

#2 @GaryJ
15 years ago

Will that extra argument be backwards compatible?

Could you add some code such that if source is an object rather than a string (i.e. only two arguments passed in), that source = options.source?

#3 @scribu
15 years ago

That extra argument only affects the internal constructor function, which shouldn't be used directly.

If it's really necessary, sure, you could check if it's an object vs. a string or check the number of arguments passed.

#4 @sorich87
15 years ago

  • Type defect (bug)enhancement

#5 @chriscct7
12 years ago

  • Keywords needs-refresh added; has-patch removed
  • Type enhancementdefect (bug)

Needs to be refreshed

#6 @DrewAPicture
11 years ago

  • Focuses javascript added

@markjaquith: Could you please take a look at this and give it a yea or nay? It's been out there for four years, not sure if it's still worth pursuing.

#7 @obenland
10 years ago

  • Keywords needs-refresh removed
  • Milestone Awaiting Review
  • Resolutionwontfix
  • Status newclosed

suggest.js is unused in Core as of [38797].

Note: See TracTickets for help on using tickets.