javascript - Load scripts in bootstrap modal when getting fragment of page -
i'm getting fragment of page , loading in bootstrap modal.
this fragment of page includes jquery required load google maps when modal loads content, scripts getting stripped subsequently, maps don't load.
even if directly insert scripts inside modal-body class, still stripped.
is there workaround @ all?
what we're using trigger modal is:-
<a href="/stores .topclass" data-target="#storesmodal" data-toggle="modal">launch demo modal</a>
i can provide further code in use if needed answer accurately.
=== edit: providing more code in use on request...
so we're including sitewide link triggers bootstrap modal. link triggering modal can seen above , here rest of code in relation modal.
what wish load in modal fragment of page @ /stores
, code loaded @ url can seen here. page though, wish load inside .modal-container on line 192 necessary scripts reside outside of div in same file, aren't capturing when try load in modal. previously, our modal trigger looked like:-
<a href="/stores .modal-container" data-target="#storesmodal" data-toggle="modal">launch demo modal</a>
this led try , wrap entire file content inside div , call it's contents fragment of page in modal can pull necessary scripts required load #map_canvas alas, scripts stripped out of modal...
hope gives greater explanation we're trying achieve.
=== edit 2: we've fixed via workaround mammoth job post answer can...
i'm using following code load view on boostrap modal :
$('[data-toggle="modal"]').click(function(e) { e.preventdefault(); var url = $(this).attr('href'); if (url.indexof('#') == 0) { $(url).modal('open'); } else { $.get(url, function(data) { $(data).modal(); }).success(function() { $('input:text:visible:first').focus(); }); } });
with following trigger :
<a href="new" role="button" data-backdrop="static" data-keyboard="false" class="btn btn-success" rel="tooltip" data-placement="top" title="text here" data-toggle="modal" alt="text here"><i class="icon-plus icon-white"></i> </a>
by using method ensure script loaded when modal display. workaroung found correctly showing modal.
everything have show on form (new.html) displayed perfectly.
thus, suggest put releavant code google map
on page corresponding /stores
.
edit trigger should :
<a href="/stores" class="topclass" data-target="#storesmodal" data-toggle="modal">launch demo modal</a>
instead of :
<a href="/stores .topclass" data-target="#storesmodal" data-toggle="modal">launch demo modal</a>`
edit2
the problem see, modal inclusion not js files because these not within inclusion section. i'm not php expert, here option might try :
option1 (not clean)
you can add <script>google map required js file</script>
tag inside <div class="modal-container"></div>
duplicate tag same js file.
option2 (might possible ?)
create new file , add section <div class="modal-container"></div>
required js files.
replace line 192 including new file , call modal passing current store object in order display information in modal.
let me know if help.
Comments
Post a Comment