Skip to content

make the hidden input fire "onchange" so to work with AS#update_columns feature #7

@clyfe

Description

@clyfe

When I use a RS column in AS
that trigers updates for other columns in the form via AS#update_column feature,
the other columns don't get updated!

This happens because:

1 ==

The RS helper record_select_field does not put the right "options" (id, classes) on the hidden input field. Example (how it should be):

<%
scope ||= nil
options = active_scaffold_input_options(column, scope).merge(
  :class => 'template-input text-input', :size => 30
)
options[:id] +=  '_select' if options[:id]

hidden_options = active_scaffold_input_options(column, scope)
hidden_options = update_columns_options(column, scope, hidden_options)
hidden_options[:id] +=  '_hidden' if hidden_options[:id]
%>
<dl>
  <dt>
    <label for="<%= active_scaffold_input_options(column, scope)[:id] %>"><%= column.label %></label>
  </dt>
  <dd>

    <%= record_select_field 'template', Project.new,
      {:controller => 'utilisation/projects'}, options, hidden_options %>

The record_select_field helper must be modified to accept extra params. This can be done in an unobtrusive way (using default params). Theese paramse are to be forwarded to JS RecordSelect.Single (so it can set the hidden input field options like (id, class)

2 ==

The hidden input does not fire "onchange" event.
This can be fixed with a this.hidden_input.trigger('change'); (jquery) inside RecordSelect.Single#add.
Because Prototype's Event.fire as of current version only works with custom events we must use this.hidden_input.simulate('change'); via https://github.com/kangax/protolicious/blob/master/event.simulate.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions