Amongst the components in my page, I have an alert dialog which I made from an overlay block, containing a panel (which acts as the dialog box).
The purpose of the overlay is to receive clicks outside the alert, to discard it.
In the alert panel, I have a text box which I populate with data item coming from a repeatable)
The problem is the following :
When I set the data model to the alert panel, it does not work, and I get no text (properties are ‘undefined’)
When I set the data model to the underlying overlay block, it does work fine.
Why would that be, and would it not be cleaner if the data model of the panel itself worked ?
Yes, as much as I can find a workaround for a simple modal alert dialog, It becomes a nightmare with a modal form where I have to pre-populate select components, and deal with many fields, because data binding won’t work (form data model does not get set, just like this more simple example).
other way of putting the question : how can I have a working modal alert (or form) ?
As it happens, this eventually works (though i’ prefer having my alert within the overlay, and have a single visibility toggle for the whole modal, but as exposed, this does not work).
So I can replicate this for a more elaborate Form. Except that there is a show stopper issue with the select components in the form.
I already had a ticket openened for this (select with data binding does not behave correctly in this case. It does not want to change value) :
Now, since I need to get forward, I tried to find a workaround, and set the select value manually (no data binding) :
Most likely, the error means that when the block “Get component by id - Form_select_location” is called, the Form_select_location selecnt is not on rendered. Is it rendered? Where is that select located so I can check?
As a summary, I have tried 2 methods for gettings things done, and I’m working on a third (the workaround of the workaround), which gets me other troubles as well …
set data model to the form, and bind the form field, including select
Does not work because select does not want to change when changed (this is a backendless bug, ticket openend by Serguey ) …
You can find the behaviour on the ‘sandbox’ page of my app.
set data model to the form, and bind the form field, but not select - select is set manually
Does not work because select is ‘undefined’, despite beeing actually rendered …
You can find the behaviour on the ‘locataires’ page of my app.
Now I’m working on a third (!) method, which gives correct results regarding the ‘select’
3) set a page variable with the data, and bind the form to this page data excluding select . select has to be bound to an other page variable to work !
But this method does not work properly because when I want a fresh form, it does not want to reset:
Also, I mention that i had tried a fourth method initially, which did not work AT ALL, by embedding the form into a block. Nothing in the form was accessible when toggling visibility. Now I have to deal with separate shadow / overlay for making my form being modal …
Suggestion : somenone at Backendless makes a working modal component, because honestly, I have spent many hours on this which could have been used more productively …
(Nevertheless, I thank you for the time you take on this thread).
Is it possible to handle that in a straight way? What I mean is - do not use data model or reset form blocks. Just write some object in page data when the modal is opened and you already know what you will be editing. Store it like - editingObject and bind everything to this object in page data, all other actions like reset form also handled in a simple way. In the reset form example just rewrite this object with the new empty object and so on.
Thanks for your insight.
If I understand you correctly, this is indeed the 3rd method I’m using.
It does work, with 2 caveats :
the select component into the form cannot be bound to this editingObject (in my case it’s item_selected) because of upstream bug (there is a ticket for this)
I wanted to make an empty object independant of its model (so that I don’t have to rewrite things if database model changes), but I did not succeed so far … (see post Weird logic Variable behaviour)
If you have a way to make an object with all its properties set to null, without explicitely assigning all of them, I’m a happy camper …