ajax
This commit is contained in:
parent
8618ad3ede
commit
9cd931cb7f
|
@ -311,11 +311,12 @@ class ProjectsController < ApplicationController
|
|||
:is_readed => false}
|
||||
|
||||
@jfm = Project.add_new_jour(nil, nil, project_id, options)
|
||||
@save_succ = @jfm.errors.empty?
|
||||
|
||||
# flash[:notice]=l(:label_projects_feedback_respond_success)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
# format.html { redirect_to :back }
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<%= form_tag({:controller => 'projects', :action => 'project_respond'}) do %>
|
||||
<%= form_tag({:controller => 'projects', :action => 'project_respond'}, :remote => true) do %>
|
||||
<%= text_area_tag 'project_respond', "",
|
||||
:class => 'noline', :required => true,
|
||||
:style => "resize: none;", :rows => 3,
|
||||
|
|
|
@ -1,3 +1,40 @@
|
|||
<script>
|
||||
var W3CDOM = document.createElement && document.getElementsByTagName;
|
||||
|
||||
window.onload = setMaxLength;
|
||||
|
||||
function setMaxLength() {
|
||||
if (!W3CDOM) return;
|
||||
var textareas = document.getElementsByTagName('textarea');
|
||||
for (var i=0;i<textareas.length;i++) {
|
||||
var textarea = textareas[i];
|
||||
setMaxLengthItem(textareas[i]);
|
||||
}
|
||||
}
|
||||
function setMaxLengthItem(textarea){
|
||||
if (textarea.getAttribute('maxlength')) {
|
||||
var counter = document.createElement('div');
|
||||
counter.className = 'counter';
|
||||
var counterClone = counter.cloneNode(true);
|
||||
counterClone.innerHTML = '<span>0</span>/'+textarea.getAttribute('maxlength');
|
||||
textarea.parentNode.insertBefore(counterClone,textarea.nextSibling);
|
||||
textarea.relatedElement = counterClone.getElementsByTagName('span')[0];
|
||||
textarea.onkeyup = textarea.onchange = checkMaxLength;
|
||||
textarea.onkeyup();
|
||||
}
|
||||
}
|
||||
|
||||
function checkMaxLength() {
|
||||
var maxLength = this.getAttribute('maxlength');
|
||||
var currentLength = this.value.length;
|
||||
if (currentLength > maxLength)
|
||||
this.relatedElement.className = 'toomuch';
|
||||
else
|
||||
this.relatedElement.className = '';
|
||||
this.relatedElement.firstChild.nodeValue = currentLength;
|
||||
}
|
||||
|
||||
</script>
|
||||
<!-- fq -->
|
||||
<h3><%= l(:label_user_response) %></h3>
|
||||
<div style="width: 80%; margin-left:10%;">
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<% if @save_succ %>
|
||||
var pre_append = $('<%= j(
|
||||
render :partial => "words/journal_reply_items",
|
||||
:locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm}
|
||||
) %>').hide();
|
||||
$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append);
|
||||
pre_append.fadeIn(600);
|
||||
var textarea = $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea');
|
||||
textarea.val('');
|
||||
$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide();
|
||||
setMaxLengthItem(pre_append.find('textarea')[0]);
|
||||
<% else %>
|
||||
alert("<%= l(:label_feedback_fail) %>");
|
||||
<% end %>
|
Loading…
Reference in New Issue