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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:03:09+00:00 2026-06-05T04:03:09+00:00

Maybe I’m on the wrong track… The setup: I have a rather complex full

  • 0

Maybe I’m on the wrong track…

The setup:
I have a rather complex full dojofied web application. The important part for this question is a longish form in the central region of a dijit.layout.BorderContainer with a navigation tree and some action buttons in the other regions.

What I want to do:
If the user did enter data and did not save, they should get a warning message if he is going to leave the form (if he navigates away, klicks the “new Element” button,…). For a better user experience, I wanted to give a modal dialog with the options “save”, “leave anyway”, “cancel”.
May idea was to use the onBlur event of the form, stop all other events (most likely an onClick on some other widget), check for changes, if there are changes, display the dialog, otherwise let the other events continue.
I do not want to add a checkChanges method to all non-form active elements!

For a first test I just tried to stop the events…

This works

<div id="formArea" dojoType="dijit.form.Form" encoding="multipart/form-data" action=""  class="ContentPane" region="center">
   <script type="dojo/connect" event="onBlur" >
      alert("I don't think so");
    </script>
 </div>

…but it’s ugly and I can’t easily continue

This doesn’t

<div id="formArea" dojoType="dijit.form.Form" encoding="multipart/form-data" action=""  class="ContentPane" region="center">
   <script type="dojo/connect" event="onBlur" args="e">
      console.log("blur"); // ok
      e.preventDefault();//event.stopt(e)//return false //<--neither of these
    </script>
 </div>

the problem is that if I click on a button outside of the form, the onBlur triggers, but I can’t stop the onClick on the button.
I know that onBlur doesn’t deliver an event object – so the e.something can’t really work…
Is there any way to catch the onClick on the other element?

  • 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-05T04:03:10+00:00Added an answer on June 5, 2026 at 4:03 am

    there is afaik only confirm('question?') that will ‘deadlock’ the events of your page like that.

    I have made a similar setup though, the way I came around this (except if user enters url in addressbar and hits enter) was a popup dialog whenever the navigation tree is clicked, sending user to a new view. Consider:

    ----------------------------------------
    | Nav 1  |   Asset1 ( view controller )  |
    | Nav 2  |   Asset2 ( hidden )           |
    ----------------------------------------
    

    Nav 1 is the default onload view, Asset 1 is loaded, contains a ‘setup page’ form or similar and can be changed. The trick is, Asset1 and Asset2 is derivative from AbstractAsset which in turn is a simple ContentPane extension.

    In AbstractAsset is a ‘must-override-for-functionality’ function called isDirty

    var Viewcontroller = declare("AbstractAsset", [dijit.ContentPane], {
           isDirty: function() { return false; }
    });
    
    
    declare("Asset1", [Viewcontroller], {
    
    startup: function() {
      // sets up form
      ...
      // and references inputfields to 'this'
      this.inputfields = this.form.getChildren();
    
      // and saves (clones) the state of each field
      var self = this;
      this.inputfields.forEach(function(inputWidget) {
         self.states[inputWidget.id] = inputWidget.get("value");
      });
    },
    isDirty: function() {
      var self = this;
      var dirty = false;
      this.form.getChildren().some(input) {
         if(self.states[input.id] != input.get("value")) {
            dirty = true;
            return false; // breaks .some loop
         }
         return true;
      });
      return dirty;
    }
    
    })
    

    Then in turn, every navigation click must call the currently visible view controller’s isDirty function in order to procede. Lets say user clicks the nav-tree (dijit.Tree) row node Nav 2.

    var navigation = dojo.declare("NavigationController", [dijit.Tree], {
     currentView : null,
     onLoad: function() {
       // start Asset1 in viewNode by default
       this.currentView = new Asset1({ }, this.viewNode); 
     },
     onClick : function() {
        if(this.currentView.isDirty()) alert("I Dont Think So");
        else {
           this.loadFunction(this.model.selection.getSelected());
        }
     }
    
    });
    

    This is the general idea of implementing the on-unload-check, you Will need to hook any onClick events through your ‘master application controller’ to determine what should happen. Check this application which serves as cms navigation controller and its page.js:587 for isDirty example

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

Sidebar

Related Questions

Maybe someone can help me out. I have created a simple web user control,
Maybe this is a dumb question! I'm just wandering is there any way/web part
Maybe I'm not seeing it, but what's wrong with specifying the group? Difficulty querying
Maybe this is just how unapproved actions work (we're still testing)... I have gone
Maybe this is a simple question, but I didn't find answer in web. I
Maybe I am out of my mind right now, but I have a question
Maybe this is very basic, but I am all confused. I have a simple
Maybe I am being stupid, but this isn't making sense to me... I have
Maybe a silly question but here goes anyway. Example: Let's say I have one
maybe i am understanding it all wrong but as i understood the best way

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.