Module: DependentSelect

Defined in:
lib/dependent_select/dependent_select.rb

Defined Under Namespace

Modules: FormHelpers, IncludesHelper

Class Method Summary collapse

Class Method Details

.collapse_spaces=(value) ⇒ Object

By default, spaces are collapsed on browsers when printing the select option texts For example:

<select>
   <option>This  option    should   have      lots of       spaces   on its text</option>
</select>

When you browse that, some browsers collapse the spaces, so you get an option that says

"This option should have lots of spaces on its text"

Setting collapse_blanks to false will replace the blanks with the &nbsp; character, using javascript

option_text.replace(/ /g, "\240"); // "\240" is the octal representation of charcode 160 (nbsp)


24
25
26
# File 'lib/dependent_select/dependent_select.rb', line 24

def self.collapse_spaces=(value)
  default_options[:collapse_spaces] = value
end

.collapse_spaces?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/dependent_select/dependent_select.rb', line 28

def self.collapse_spaces?
  default_options[:collapse_spaces]
end

.default_optionsObject

Returns the default_options hash. These options are by default provided to every calendar_date_select control, unless otherwise overrided.

Example:

# At the bottom of config/environment.rb:
DependentSelect.default_options.update(
  :collapse_spaces => false
)


10
11
12
# File 'lib/dependent_select/dependent_select.rb', line 10

def self.default_options
  @default_options ||= { :collapse_spaces => true, :use_jquery => false }
end

.use_jquery=(value) ⇒ Object

By default, dependent_select will use Prototype. If you need to use jquery, you can do so by doing

DependentSelect.use_jquery = true


34
35
36
# File 'lib/dependent_select/dependent_select.rb', line 34

def self.use_jquery=(value)
  default_options[:use_jquery] = value
end

.use_jquery?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/dependent_select/dependent_select.rb', line 38

def self.use_jquery?
  default_options[:use_jquery]
end