Place <script> tag within Featherlight.js modal

163 Views Asked by At

I am trying to place the following <script> tag within a featherlight.js modal window however it's just displaying as plain text.

I need to be able to perform an ajax request on a form within the featherlight.js window.

<script type="text/javascript">
$('#customerOrderNoteAdd').on('submit',function(e){
    e.preventDefault();
    var formData = $(this).serializeArray();
    var formURL = $(this).attr('action');
    $.post(formURL,formData,function(data){
        data = $.parseJSON(data);
        if(data.success){
            alert("Sent");
        }
    });
});
</script>
1

There are 1 best solutions below

0
On

The <script> tag doesn't need to be "in" the dialog. Moreover, you're not mentionning which content filter you are using.

Anyways, you could make your binding generic ($(document).on('submit', '#customerOrderNoteAdd', ...) and run it once on startup, or else run your script in an afterContent callback.