javascript - Inject values into html function via jQuery on modal -


i have trigger button modal, passing id , value.
in script section need "inject" form modal-body.
my problem pass variables in html function of script. how it?

html

<button value="{{ $etapaano->trabalho_id }}" id="{{ $etapaano->id }}" class="btn btn-primary btn-sm" title="enviar arquivo" data-toggle="modal" data-target="#mymodaluploadarquivos"><i class="fa fa-upload"></i> enviar</button>   <div id="mymodaluploadarquivos" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true">     <div class="modal-dialog">         <div class="modal-content">             <div class="modal-header">                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>                 <h4 class="modal-title" id="mymodallabel">submeter arquivo</h4>             </div>             <div id="modalbodyarquivo" class="modal-body">              </div>            </div>     </div> </div> 

script

$('#mymodaluploadarquivos').on('show.bs.modal', function(e) {             var $modal = $(this);     var etapaanoid = e.relatedtarget.id;     var trabalhoid = e.relatedtarget.value;               $('#modalbodyarquivo').html('<form method="post" enctype=multipart/form-data action="{{ url("arquivo/store/etapaanoid/trabalhoanoid") }}" file="true">{{ csrf_field() }}<label for="descricao">arquivo *</label><input type="file" name="descricao" /></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">fechar</button><button id="enviaarquivo" type="submit" class="btn btn-primary pull-right" title="enviar arquivo">enviar</button></div></form>'); }); 

try replacing this:

"{{ url("arquivo/store/etapaanoid/trabalhoanoid") }}" 

with this:

"{{ url("arquivo/store") }}/'+etapaanoid+'/'+trabalhoanoid+'" 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -