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

  • SEARCH
  • Home
  • 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 7278915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:56:31+00:00 2026-05-28T22:56:31+00:00

I have a snippet of jQuery $(function () { $(‘.checked’).click(function (e) { e.preventDefault(); var

  • 0

I have a snippet of jQuery

$(function () {
    $('.checked').click(function (e) {
        e.preventDefault();
        var dirtyvalue = "Test1";
        var textvalue= "Test";

        if (dirtyvalue.toLowerCase() != textvalue.toLowerCase()) {

            {
                var dialog = $('<p>Do you want to save your changes?</p>').dialog({
                    buttons: {
                        "Yes": function () {
                            dialog.dialog('close');
                            alert('yes btn called');

                        },
                        "No": function () {
                            dialog.dialog('close');
                            alert('No btn called');

                        },
                        "Cancel": function () {
                            dialog.dialog('close');

                        }
                    }
                });
            }
            return false;
        }
        return true;

    });
});

I want to return true or false on button click; ‘Yes’ should return true, ‘No’ should return true, and ‘Cancel’ should return false.

I already checked this link, but this is not solving my problem.
See also my previous question.

My scenario is that I have many ActionLink and TreeView links which navigate to their respective pages. Suppose I am on page 1 where I have this JS, and on that page I have many action links. Clicking on page 2, at that time my confirm should open, and when I click on the button ‘No’ it should redirect to page 2.

  • 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-05-28T22:56:32+00:00Added an answer on May 28, 2026 at 10:56 pm

    A dialog can’t return a value, you must put what you want to do in another function. for example

            var dialog = $('<p>Are you sure?</p>').dialog({
                buttons: {
                    "Yes": function() 
                           {
                             alert('you chose yes');
                             //call a function that redirects you
                             function_redirect(true);
                           },
                    "No":  function() 
                           {
                             alert('you chose no');
                              //call a function that redirects you
                             function_redirect(true);
                           },
                    "Cancel":  function() 
                               {
                                alert('you chose cancel');
                             //just close the dialog
                                dialog.dialog('close');
                               }
                }
            });
    
    var function_redirect = function(redirect){
       if(redirect === true){
           //redirect to page2
        }
    }
    

    you should put the logic you need to implement in “function_redirect” (or in whatever function you want) and pass parametrs according to the button pressed

    EDIT – if you need to know what button has been clicked, just use the event object that is passed to the function

     "Yes": function(e) {
          //e.target is the element of the dom that has been clicked 
          //from e.target you can understand where you are and act accordingly
          //or pass it to function_redirect
          function_redirect(true, e.target);
    
    var function_redirect = function(redirect, target){
       if(redirect === true){
           if($(target).parent().attr('id') === 'page2'){
              //redirect to page2
           }else{
             //do something else
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little snippet in jQuery $('.cake_checkboxes').click(function(){ $(this).nextAll('.quantity').first().slideToggle(); }); here is my html
I have a working script like this: jQuery(document).ready(function(){ $('.video-thumb img').bind('mouseover',function(){ var new = $(this).attr('src').replace(/default.jpg/,'1.jpg');
I have this jQuery snippet: $(function() { $(ul > li).hover(function() { $(this).find(ul).stop(true, true).animate({opacity: 'toggle'},
I have following code (html,js,jquery) snippet ( http://jsfiddle.net/MUScJ/2/ ): <script type=text/javascript> function someFunc(){ html
Hello I have this snippet of jQuery code jQuery(document).ready(function($) { $.get(<?echo $site['url'];?>modules/tuitting/tuitting_core/classes/count.php, function (data)
jQuery('ul#reorderps ul ul li').mouseover( function(){ jQuery(this).css(cursor,pointer); var position= jQuery(this).position(); jQuery(#up).click(function() { alert('hey'); }); }
I have a small jquery snippet that displays notification message at the top of
I have the following snippet of code (I'm using jQuery 1.4.2): $.post('/Ads/GetAdStatsRow/', { 'ad_id':
I have a jQuery snippet written where if any of my inputs in a
I have a super long jquery snippet that I feel could be simplified with

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.