Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8695915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:09:19+00:00 2026-06-13T01:09:19+00:00

I am using jquery modal, within each modal I have a form. I am

  • 0

I am using jquery modal, within each modal I have a form. I am then loading certain jquery functions onto the form elements, for example jquery autocomplete.

When I open the modal for the first time it is working fine with all the jquery functions within the script, but as soon as I close the first modal and open again none of the functions work.

Its as though they are binded on the page load to the form, then when the button is clicked for the modal its works and then closing the modal unbinds it.

Does anybody have any ideas as to why they would stop working after the first modal open/close?

$(document).ready(dialogForms);
function dialogForms() {    
 $('a.menubutton').click(function() {
    var a = $(this);
    $.get(a.attr('href'),function(resp){
      var dialog = $('<div>').attr('id','formDialog').html($(resp).find('form:first').parent('div').html());
      $('body').append(dialog);
      dialog.find(':submit').hide();
      dialog.dialog({
        title: a.attr('title') ? a.attr('title') : '',
        modal: true,
        buttons: {
          'Save': function() {

                if($(this).find('form').valid()){
                // do stuff if form validates
                submitFormWithAjax($(this).find('form'));               
                $('#homepage').trigger('click');    
                $(this).dialog('close');
                } 
                else {

                }             
                },
          'Cancel': function() {$(this).dialog('close');}
        },
        width: 650,
        height: 400,        
        show: "fade",
        hide: "fade"
      });

$('#edit_vle').bind('change', function (e) { 
    if( $('#edit_vle').val() == 'FE') {
      $('#fe_automcomplete1').show();
      $('#he_automcomplete1').hide();
      $("#edit_he_title").val("");
      $("#edit_he_code").val("");
    }
    else{
      $('#fe_automcomplete1').hide();
      $('#he_automcomplete1').show();
      $("#edit_fe_title").val("");
      $("#edit_fe_code").val("");
    }         
});


$('#delete_vle').bind('change', function (e) { 
    if( $('#delete_vle').val() == 'FE') {
      $('#fe_automcomplete2').show();
      $('#he_automcomplete2').hide();
      $("#delete_he_title").val("");
      $("#delete_he_code").val("");
    }
    else{
      $('#fe_automcomplete2').hide();
      $('#he_automcomplete2').show();
      $("#delete_fe_title").val("");
      $("#delete_fe_code").val("");
    }         
});


    var epronames = [<?php 
    $eprotmp = Array();
    while($eprorow = mssql_fetch_array($epro_course)) $eprotmp[] = 
    '{
                title: "'.$eprorow['Name'].'",
                label: "'.$eprorow['Code'].' - '.$eprorow['Name'].'",
                code: "'.$eprorow['Code'].'",
                user: "'.$eprorow['fname'].' '.$eprorow['sname'].'",
    }'; 
    echo join(',', $eprotmp);
?>];

    var fenames = [<?php 
    $fetmp = Array();
    while($ferow = mysql_fetch_array($feinactive)) $fetmp[] = 
    '{
                title: "'.$ferow['course'].'",
                label: "'.$ferow['shortname'].' - '.$ferow['course'].'",
                code: "'.$ferow['shortname'].'",
    }'; 
    echo join(',', $fetmp);
?>];

    var henames = [<?php 
    $hetmp = Array();
    while($herow = mysql_fetch_array($heinactive)) $hetmp[] = 
    '{
                title: "'.$herow['course'].'",
                label: "'.$herow['shortname'].' - '.$herow['course'].'",
                code: "'.$herow['shortname'].'",
    }'; 
    echo join(',', $hetmp);
?>];

        $("#title").autocomplete({
            minLength: 3,
            source: epronames,
            focus: function( event, ui ) {
                $("#title").val( ui.item.label );
                return false;
            },
            select: function( event, ui ) {
                $("#title").val( ui.item.title );
                $("#code").val( ui.item.code );
                $("#ctl").val( ui.item.user );
                return false;
            },
            change: function(event, ui) {
            if (!ui.item) {
                $("#title").val("");
            }
            }
        })
        .data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.label + "</a>" )
                .appendTo( ul );
        };



        $("#edit_he_title").autocomplete({
            minLength: 3,
            source: henames,
            focus: function( event, ui ) {
                $("#edit_he_title").val( ui.item.label );
                return false;
            },
            select: function( event, ui ) {
                $("#edit_he_title").val( ui.item.title );
                $("#edit_he_code").val( ui.item.code );
                return false;
            },
            change: function(event, ui) {
            if (!ui.item) {
                $("#edit_he_title").val("");
            }
            }
        })
        .data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.label + "</a>" )
                .appendTo( ul );
        };



        $("#edit_fe_title").autocomplete({
            minLength: 3,
            source: fenames,
            focus: function( event, ui ) {
                $("#edit_fe_title").val( ui.item.label );
                return false;
            },
            select: function( event, ui ) {
                $("#edit_fe_title").val( ui.item.title );
                $("#edit_fe_code").val( ui.item.code );
                return false;
            },
            change: function(event, ui) {
            if (!ui.item) {
                $("#edit_fe_title").val("");
            }
            }
        })
        .data( "autocomplete" )._renderItem = function( ul, item ) {
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.label + "</a>" )
                .appendTo( ul );
        };      






if($("#clearform").length > 0){
$("#clearform").click(function() {
    $("#title").val('');
    $("#code").val('');
    $("#ctl").val('');
});
}

if($("#delete_fe_clearform").length > 0){
$("#delete_fe_clearform").click(function() {
    $("#delete_fe_title").val('');
    $("#delete_fe_code").val('');
});
}
if($("#edit_fe_clearform").length > 0){
$("#edit_fe_clearform").click(function() {
    $("#edit_fe_title").val('');
    $("#edit_fe_code").val('');
});
}

if($("#delete_he_clearform").length > 0){
$("#delete_he_clearform").click(function() {
    $("#delete_he_title").val('');
    $("#delete_he_code").val('');
});
}
if($("#edit_he_clearform").length > 0){
$("#edit_he_clearform").click(function() {
    $("#edit_he_title").val('');
    $("#edit_he_code").val('');
});
}


}, 'html');
return false;
});

}

function submitFormWithAjax(form) {
  form = $(form);
  $.ajax({
    url: form.attr('action'),
    data: form.serialize(),
    type: (form.attr('method')),
    dataType: 'script',
    success: function(data){
   }
  });
  return false;
}

Here are the buttons for each modal.

<a href="new_course.php" class="menubutton" id="new_course" title="New Course">New Course</a>
<a href="edit_course.php" class="menubutton" id="edit_course" title="Edit Course">Edit Course</a>
<a href="delete_course.php" class="menubutton" id="delete_course" title="Delete Course">Delete Course</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:09:21+00:00Added an answer on June 13, 2026 at 1:09 am

    I placed the jquery functions into the open method

    open: function(){
    

    To close the dialog instead of using:

    $(this).dialog('close');
    

    I used

    dialog.remove();
    

    My functions now work every time i open the dialog

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an update panel within a div that I modal using the JQuery
I am having difficulty using JQuery UI Modal Dialog when submitting a form. The
I'm using a few jQuery UI modal dialogs and the positioning of each dialog
I m havin a jqueryui modal form. and i m using jquery cluetip tool
I have a modal window using jqmodal. I need a button within that modal
I'm just starting to use JQuery, and I'm editing the modal popup example within
I have a form within a SimpleModal modal, but when I try to use
I'm using the jquery dialog in my ASP.net web app. Within it I have
I'm using jQuery UI Selectmenu to style a form's dropdowns. I've created an example
I have a jQuery UI modal dialog, and it shows up right. Then, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.