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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:34:51+00:00 2026-06-15T12:34:51+00:00

I am writing a simple form with Dojo. This is my very first real

  • 0

I am writing a simple form with Dojo. This is my very first “real” use of Dojo in terms of actually doing something…
Basically:

1) When the widget is shown, onShow, it tries to pre-load the values the form should have
2) When the user submits, the values are saved using the same store

The “problem” here is that I am trying to make a 1000% failsafe application. For example, if the store doesn’t work (and therefore settings cannot be retrieved), I would like to application to try again after 3 seconds — or, well, when the user clicks on a link.
So, what I am doing now is place all of the “fetching” functionality into a function, loadUp(). If there is a problem, I will run loadUp() again (from the error callback in the promise) AND I should also disable the form — something like turning it grey, and now allowing input).

So, questions:

1) Is this a sane way of doing things?
2) How would you go, about greying out the form?

I realise that I am talking about the Workspace settings here. So, what will really happen is that the “get” will be done at the very beginning of the whole process. However, I will reuse this for pretty much every form…

Here is the code:

var SettingsGeneral = declare('hotplate.bd.SettingsGeneral', [ ContentPane, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], { 

 templateString: '' + 
 '<div>' + 
 '  <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="form" method="POST"> ' + 
 '    <input id="${id}_WorkspaceLongName" data-dojo-type="dijit/form/ValidationTextBox" name="longName" data-dojo-props="" />' + 
 '    <input id="${id}_WorkspaceTag" data-dojo-type="dijit/form/ValidationTextBox" name="tag" data-dojo-props="" />' + 
 '    <input class="formSubmit" type="submit" data-dojo-attach-point="button" data-dojo-type="hotplate.hotDojoWidgets.BusyButton" label="Create!" />' + 
 '  </form>' + 
 '</div>', 

onShow: function(){ 
  this.inherited(arguments); 

  // This returns a working store 
  var workspaceSettings = stores('workspaceSettings', { workspaceIdCall: vars['hotDojoAppContainer']['workspaceId'] } ); 

  function loadUp(){ 

   // The server will return the settings for this particular workspace 
   workspaceSettings.get('').then( 
      function(res){ 

        // All good... 

        // Assign all of the received values to matching fields 
        // TODO: Turn this into a function 
        that.form._descendants.forEach(function( widget ) { 
          console.log(widget); 
          if( typeof( res.data[ widget.name ] ) !== 'undefined'){ 
            widget.set('value', res.data[ widget.name] ); 
          } 
        }); 

      }, 
      function(err){ 

        // Error: try this again in 3 seconds, hopefully it will work. It would actually be better having a 
        // link to click for the user 

        console.log("Something went wrong. The form needs to be disabled (turned grey?) and the connection should be retried"); 
        setTimeout(loadUp, 3000); 
      } 
    ); 
  }; 
  loadUp(); 

  // Submit form 
  this.form.onSubmit = ds.defaultSubmit(this.form, this.button, function(){ 
     console.log("PRESSED!"); 
     that.button.cancel(); 

    console.log(workspaceSettings); 

    // Use the same data store to save the settings... 

  }); 
} 
}); 
  • 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-15T12:34:52+00:00Added an answer on June 15, 2026 at 12:34 pm

    Here is what I did:

    STEP 1: I added a mixin to my class: _OverlayMixin, and set onOverlayClick to re-show the widget. I also run this.set( 'overlayed', true ); this.set( 'overlayClickable', false ); as soon as show() is called, and then that.set( 'overlayed', false ); (If things worked OK) or that.set('overlayClickable', true ); (if things don’t go well).

    STEP 2: Actually wrote the _OverlayMixin class

    The code follows. The _OverlayMixin class is really simple, self-contained. It needs prettifying — right now it’s just a gray thing over the widget. If the overlay is clickable, it will have a class set — so it might have an icon for retrying. I like what I did, because it’s very dojo-ish, and it’s just so simple to read. Also, this way the widget can be “restarted” easily by the user if things go wrong.

    Here is the code… starting from my simple widget:

    var SettingsGeneral = declare('hotplate.bd.SettingsGeneral', [ ContentPane, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _OverlayMixin ], { 
    
    templateString: '' + 
     '<div>' + 
     '  <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="form" method="POST"> ' + 
     '    <input id="${id}_WorkspaceLongName" data-dojo-type="dijit/form/ValidationTextBox" name="longName" data-dojo-props="" />' + 
     '    <input id="${id}_WorkspaceTag" data-dojo-type="dijit/form/ValidationTextBox" name="tag" data-dojo-props="" />' + 
     '    <input class="formSubmit" type="submit" data-dojo-attach-point="button" data-dojo-type="hotplate.hotDojoWidgets.BusyButton" label="Create!" />' + 
     '  </form>' + 
     '</div>', 
    
    
    onOverlayClick: function(){ 
      this.onShow(); 
    }, 
    
    onShow: function(){ 
    
      var that = this; 
    
      // By default, this widget is overlayed 
      this.set( 'overlayed', true ); 
      this.set( 'overlayClickable', false ); 
    
      var workspaceSettings = stores('workspaceSettings', { workspaceIdCall: vars['hotDojoAppContainer']['workspaceId'] } ); 
    
      workspaceSettings.get('').then( 
        function(res){ 
    
          // OK things worked out: the overlay can go 
          that.set( 'overlayed', false ); 
    
          // Assign all of the received values to matching fields 
          // TODO: Turn this into a function 
          that.form._descendants.forEach(function( widget ) { 
            console.log(widget); 
            if( typeof( res.data[ widget.name ] ) !== 'undefined'){ 
              widget.set('value', res.data[ widget.name] ); 
            } 
          }); 
        }, 
        function(err){ 
          that.set('overlayClickable', true ); 
        } 
      ); 
    
    }, 
    

    The mixin:

    define([ 
    "dojo/_base/declare", 
    "dojo/on", 
    "dojo/dom", 
    "dojo/dom-construct", 
    "dojo/dom-attr", 
     "dojo/dom-class", 
    
    ], function( 
     declare 
    , on 
    , dom 
    , domConstruct 
    , domAttr 
    , domClass 
    ){ 
    return declare( null, { 
    
    overlayed: false, 
    overlayClickable: false, 
    
    postCreate: function(){ 
      var that = this; 
    
      this.inherited(arguments); 
    
      // Create the overlay widget, place it as first in the widget 
      var overlay = domConstruct.create('div', { 
        className: 'overlay', 
        style: { 
          'position': 'absolute', 
          'top': 0, 
          'bottom': 0, 
          'left': 0, 
          'right': 0, 
          'z-index': 99, 
          'display': 'none', 
          'background': 'rgba(0,0,0,0.32)' 
        } 
      } ); 
      domConstruct.place(overlay, this.domNode, 'first'); 
    
      // Set the overlayNode attribute of the widget 
      this.overlayNode = overlay; 
    
      // Wire the click of the mouse to the object's "onOverlayClick" 
      on( this.overlayNode, 'click', function(e){ 
        if( that.overlayClickable && typeof( that.onOverlayClick ) === 'function' ) { 
          that.onOverlayClick(e); 
        } 
      }); 
    }, 
    
    
    // Set the widget as "overlayed" or 
    _setOverlayedAttr: function( value ){ 
      this._set('overlayed', value); 
      if( value ){ 
        domAttr.set( this.overlayNode, { style: { display: 'block'} } ); 
      } else { 
        domAttr.set( this.overlayNode, { style: { display: 'none'} } ); 
      } 
    }, 
    _getOverlayedAttr: function(){ 
      return this.overlayVisible; 
    }, 
    
    
    // Set the widget as clickable or not 
    _setOverlayClickableAttr: function(value){ 
      console.log("Set to clickableeeeeeeeeeeeeeeeeeeeeeeeeeeeee!"); 
      this._set('overlayClickable', !! value); 
      if( value ){ 
        console.log("1"); 
        domClass.add( this.overlayNode, 'overlayClickable' ); 
      } else { 
        console.log("2"); 
        domClass.remove( this.overlayNode, 'overlayClickable' ); 
      } 
    }, 
    _getOverlayClickableAttr: function(){ 
      return this.overlayClickableAttr; 
    } 
    
    
    
    });  
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a simple first app using Winforms, C#, VS2010, and Entity Framework. Basically,
I am considering making a very simple form for clients to use in a
I'm writing a simple linked list based memory manager in the form: ...Header|Block|Header|Block... with
I'm writing simple filter in Android and want to use ExpandableListAdapter with check boxes.
I'm stuck writing a simple form...I feel dumb. Here's my controller: function welcome_message(){ //Update
I am writing a simple form submit function for a specific site. The script
I'm writing a simple javascript form that checks the input value against the value
I was writing a simple login form, everything works fine (validation etc.) but I
I'm writing a simple search form for a certain model. Let's call the model
I'm writing a simple JavaScript form, it is a list of devices with a

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.