The theme_jquery_colorpicker() function generates an id with a random number. What is the use of this? I cant use it for CSS or target it with jquery as it changes page to page. There might as well be no id at all.
In my case I have 2 color pickers in the same form and I need to target them to listen to the change event, but being that the id changes, I can't target them.

In my case I changed
this:
$element['#id'] = isset($element['#id']) ? $element['#id'] : 'edit-' . rand(0, 9999);
to this:
$element['#id'] = isset($element['#id']) ? $element['#id'] : 'edit-' . drupal_html_class($element['#title']);

Though what I did above assumes each colorpicker form element will have a unique title.

Comments

plopesc’s picture

Issue summary: View changes
Status: Active » Fixed

Hello
Random ID's have been removed, now are generated based on parents array, as in default form elements. Current implementation is:

  if (!isset($element['#id'])) {
    $element['#id'] = drupal_html_id('edit-' . implode('-', $element['#parents']));
  }

Thank you and sorry for the late response.

  • plopesc committed 5339c03 on 7.x-1.x
    Issue #1911372 by 2pha: Fixed Random id ?.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.