Last active
February 14, 2017 05:55
-
-
Save Frank004/e3c8c801a6e0334ce739f1bd47182c96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require jquery_ujs | |
//= require jquery.remotipart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------Funcionando---- | |
<script type="text/javascript"> | |
$(document).on('submit', ".edit_inspection_component", function( e ) { | |
e.preventDefault(); | |
console.log($(this).attr('action')) | |
$.ajax( { | |
url: $(this).attr('action'), | |
type: 'PUT', | |
data: new FormData( this ), | |
processData: false, | |
contentType: false | |
}).done(function( data ) { | |
console.log(data) | |
}); | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
format.js | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= bootstrap_form_for inspection_component, remote: true, data_id: inspection_component.id do |f| %> | |
<%= f.select(:score, score_values, { :class => "form-control",label:"Puntuación" }) %> | |
<%= f.text_area :comment, label:"Comentarios"%> | |
<%= f.file_field :photo, hide_label: true , title: "Foto" %> | |
<%= f.submit 'Guardar', class: "btn btn-success" %> | |
<% end %> | |
#---------- Sugerencia-------- | |
<%= form_for inspection_component,data_id: inspection_component.id, html: {multipart: true} method: :put, remote: true do |f| %> | |
<%= f.select(:score, score_values, { :class => "form-control",label:"Puntuación" }) %> | |
<%= f.text_area :comment, label:"Comentarios"%> | |
<%= f.file_field :photo, title: "Foto" %> | |
<%= f.submit 'Guardar', class: "btn btn-success" %> | |
<%end%> | |
#------render html------- | |
<form class="edit_inspection_component" id="edit_inspection_component_11451" enctype="multipart/form-data" | |
action="/inspection_components/11451" accept-charset="UTF-8" data-remote="true" method="post"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @inspection_components.order("id DESC").each do |inspection_component| %> | |
<%= render partial: 'component_accordion', locals: {inspection_component: inspection_component} %> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form role="form" class="edit_inspection_component" id="edit_inspection_component_11451" enctype="multipart/form-data" action="/inspection_components/11451" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch"> | |
<div class="form-group"><label class="control-label" for="inspection_component_score">Puntuación</label><select class="form-control" name="inspection_component[score]" id="inspection_component_score"><option value="">Seleccione Puntuación</option> | |
<option value="10">10 - Excelente</option> | |
<option value="9">9 - Bueno</option> | |
<option selected="selected" value="8">8 - Satisfactorio</option> | |
<option value="7">7 - Regular</option> | |
<option value="6">6 - Deficiente</option> | |
<option value="5">5 - No aceptable</option></select></div> | |
<br> | |
<div class="form-group"><label class="control-label" for="inspection_component_comment">Comentarios</label><textarea class="form-control" name="inspection_component[comment]" id="inspection_component_comment">test</textarea><grammarly-btn><div style="z-index: 2; opacity: 1; transform: translate(1311px, 366px);" class="_e725ae-textarea_btn _e725ae-not_focused" data-grammarly-reactid=".3"><div class="_e725ae-transform_wrap" data-grammarly-reactid=".3.0"><div title="Protected by Grammarly" class="_e725ae-status" data-grammarly-reactid=".3.0.0"> </div></div></div></grammarly-btn></div> | |
<div class="form-group"><label class="sr-only control-label" for="inspection_component_photo">Photo</label><a class="file-input-wrapper btn">Foto<input hide_label="true" title="Foto" type="file" name="inspection_component[photo]" id="inspection_component_photo" style="left: -194px; top: 22px;"></a></div> | |
<div class="form-inline"> | |
<input type="submit" name="commit" value="Guardar" class="btn btn-success"> | |
<a class="btn btn-danger destroy_component" data-confirm="Are you sure?" data-remote="true" rel="nofollow" data-method="delete" href="/inspection_components/11451"> | |
<i class=" icon-trash "></i> | |
</a> </div></form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".score_box<%= escape_javascript(@inspection_component.id.to_s) %>").html("Puntuación: <%= escape_javascript(@inspection_component.score.to_s) %>"); | |
$("#total_score").html("<%= escape_javascript(number_to_percentage(@inspection_section.overall_score * 10,separator: '.', precision: 1)) %>"); | |
$("#<%= escape_javascript(@inspection_component.id.to_s) %>").collapse('hide'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment