Acts as drop down

Hi

Im using the acts as drop down plugin

and have this code below

acts_as_dropdown :text => “forename”, :order => “forename”

It currently makes use of the forename in the option tag, how can I get
it to use the surname as well

ie somthing like ‘forename’ . ‘surname’ in php

Thanks

still stuck on this one,

I need the select box to show both forename and surname, any
suggestions?

I think you can create a method in your model

def full_name
“#{self.forename}, #{self.surname}”
end

and then you can use the acts_as_drop_down as

acts_as_dropdown :text => :full_name, :order => “forename”, :value =>
:id

Perfect :slight_smile:

thanks

Just a quick clarification:

  1. This method would go into the model that accesses the forname and
    surname, right?
  2. and the acts_as_drop_down would go into the rhtml file that renders
    the drop down list?

Sorry it’s a bit of a newbie question, but I’m going to try to use
this… and I’m just a bit confused.
thanks
Mohit.

Hi

Is there any way for a sortable_element to execute javascript on
success? I
have a sortable list of editable objects, and whenever they are moved
they
call the ‘update_positions’ function to store the new position
information.
More than one user can update a report at the same time, and in
‘update_positions’ there is a check to see if the report has been
altered by
another user since this user started editing it. Basically i want to
refresh
the page if the data is old, but return nothing if the data is current.
I’ve
tried using :success, :complete etc in the sortable_element call but
none of
them seem to work. The only thing that seems to work is :update, but
it’s
not much use to me because i want to execute returned javascript, not
update
the whole page when most of the time there is no need to. Am I just
using
:success wrongly, or is it not supported for sortable_elements?

In my view:

<%= sortable_element(‘sortable_items’,
:tag => ‘div’,
:constraint => false,
#:success => doesn’t work?
#:complete => doesn’t work?
#:update => works but i don’t want to update every time
:url => {:controller => ‘report’, :action =>
:update_positions}) %>

In my controller:

#--------------------------------------------------------------------------

# update_positions()
# Save the positions of the report components when they are re-ordered
def update_positions
	# Security check
	unauthorised_action ParamsNotProvidedError unless params
	unauthorised_action InsufficientPrivilegesError unless

@session[:navigation][:current_report].is_writable?(@session[:user])
return false if self.auth_err

	if @session[:navigation][:current_report].has_been_modified?
		force_reload
		return false
	end

	params[:sortable_items].each_index do |i|
		item = ReportComponent.find(params[:sortable_items][i])
		item.position = i
		item.save
	end

	render :nothing => true
end

private
#--------------------------------------------------------------------------

# force_reload()
def force_reload
	render :text => "alert('data has changed blah

blah’);window.document.href=’" +
url_for(:controller => ‘report’,
:action => ‘report_builder’,
:id => @session[:navigation][:current_report].id) + “’;”
end

thanks
stan

Daniel N wrote:

def full_name
“#{self.forename}, #{self.surname}”
end


end

Hi Daniel,

Thanks for the quick reply! Appreciate it :slight_smile:
Cheers
Mohit

On 6/12/06, Mohit S. [email protected] wrote:

Just a quick clarification:

  1. This method would go into the model that accesses the forname and
    surname, right?
  2. and the acts_as_drop_down would go into the rhtml file that renders
    the drop down list?

I haven’t used this much, just played with it but I believe that you are
correct for point 1.

The acts_as_drop_down statement belongs in your model class decleration

class MyModel < ActiveRecord::Base
acts_as_drop_down :text => :full_name, :order => :forename, :value =>
:id

def full_name
“#{self.forename}, #{self.surname}”
end


end

Sorry it’s a bit of a newbie question, but I’m going to try to use

this… and I’m just a bit confused.
thanks
Mohit.

I hope it’s right, because I’m a bit of a Newbie myself :wink: