Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ruby - Rails: How to pass value from textfield to a partial -


how can pass value auto_complete textfield partial.

<%= text_field_with_auto_complete :participant, :name, {}, {:url => {:controller => "contentcom/discussions", :action => :get_users_for_auto_complete}, :method => :get, :param_name => 'search'} %>         <%= button_to_function(:ok) |page|                 page.insert_html :top, :participants, :partial => 'participant', :locals =>  end %> 

bye,

nico

first of need know helpers text_field_with_auto_complete , button_to_function not handle user actions, generate html , javascript code. generated javascript code can interact user. in case text_field_with_auto_complete generates following (approximately):

<input type="text" id="participant_name" name="participant[name]" size="15" /> <div id="participant_name_auto_complete" class="auto_complete"> </div>  <script type="text/javascript">   var participant_auto_completer = new ajax.autocompleter (     'participant',     'name',     '/contentcom/discussions/get_users_for_auto_complete',     {method: 'get', param_name: 'search'}   ); </script> 

the above code user gets in browser. if read documentation text_field_with_auto_complete, see can use option :after_update_element. option allows specify name of javascript function called when user selects 1 of proposed values.

what need do:

  1. write javascript function display anywhere user-selected value autocomplete field.
  2. call text_field_with_auto_complete :after_update_element

that's how template like:

<ul id="selected_participant_container"></ul>  <%= text_field_with_auto_complete :participant, :name, {}, {   :url => {:controller => "contentcom/discussions", :action => :get_users_for_auto_complete},   :method => :get,   :param_name => 'search',   :after_update_element => 'afterparticipantselected' }%>  <script type="text/javascript">   function afterparticipantselected (el, value) {     var container = document.getelementbyid ('selected_participant_container');      container.innerhtml = value;   } </ script> 

now, when user selects value in autocomplete field, displayed in element id = selected_participant_container

of course, can use methods proposed tokland.

but recommend first learn basics of html , javascript.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -