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 8126113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:03:00+00:00 2026-06-06T07:03:00+00:00

I have a div containing a form. I use that div as a dialog

  • 0

I have a div containing a form. I use that div as a dialog using jquery UI dialog.

There are buttons in the form. I want to call methods from my JS file attached to the view when buttons are clicked.

Somehow the dialog can not find the functions.

HTML

<div id="Applon" title="Edit Slab" style="width: 100%; background-color: #33CCCC;">
<form action="\" id="frmDtl">
....
......


<button id="dtlCancel"  type="button" onclick="this.parent.CancelDetails()" style="font-weight: bold; color: #3333FF; width:60px;">
<div><span>Cancel</span></div>  
</button>
</form>
</div>

JS file

$(function() {
//  Dialog

    $("#Applon").dialog({
        autoOpen: false,
        height: 370,
        width: 650,
        modal: true,
        buttons: {

            Close: function() {
                $(this).dialog('close');
                //$('input:visible:enabled:first').focus();
            }
        },
        close: function() {
        }
    });
});

    function CancelDetails() {
        ....
    }

I am using this in a MVC2 view in VS2008. The view has two forms one of which is a dialog.

How do i make the dialog find my functions in the JS file when button is clicked ?

Please Help.

  • 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-06T07:03:01+00:00Added an answer on June 6, 2026 at 7:03 am

    First, try and go away from inline Javascript and use selectors to fire off your functions. For instance,

    $(function() {
       $("#dtlCancel").click(function(){
         CancelDetails();
      });
    });
    

    You can place this in your modal content if it is from a separate resource (PartialView).

    Also, is your dialog an IFrame or just a modal? If it is just a modal, it is still part of the page it came from and does not need references to “parent”. Consider it a well-placed div that appears to be another page.

    EDIT

    Looking at your JS code file, it still looks like you are missing the closing brace for your $(function(){ statement

    Your Code:

    $(function() {
    //  Dialog
    
        $("#Applon").dialog({
            autoOpen: false,
            height: 370,
            width: 650,
            modal: true,
            buttons: {
    
                Close: function() {
                    $(this).dialog('close');
                    //$('input:visible:enabled:first').focus();
                }
            },
            close: function() {
            }
        });
    //From your code above (next line)
        }
    //Replace the above with this - basically add a ); after the curly brace
    });
    
        function CancelDetails() {
            ....
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a Div containing an iframe that I can Clone using JQuery.
I have a form that validates using jquery. The form's id is contact and
I have a div containing form elements, and I'm using an invisible overlay mask,
I have a form that i want to submit comments to a database containing
I have a div, containing text and a few links. I want to trigger
jQuery Mobile Docs says if we wrap form element in div containing data-role=fieldcontain proper
I have a <div id=comment_posting_holder> tag that holds a form with two elements: a
I have a facebook like system, I want the DIV containing the messages to
I have a basic page, with a div containing text, and a form to
I have a series of objects containing product information that I need to use

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.