Save button in block not closing "edit block" dialog.

Permalink
Hello everyone,

I've scoured forums many times during my programming career and have always found an answer, but this is the first time I've written my own coding problem.

What I'm doing is creating a block for selling on Concrete5 at a later stage. I've been doing this for a while and am now at the stage of pulling saved data out of the database through auto.js. A problem I've been noticing is when I edit a block (not when adding), it will not close the dialog after clicking "save" or "cancel" despite the data saving to the database as it should when clicking "save". Strangely enough, this problem seems to go after adding a new block but comes back again after pressing F5 for refresh.

After testing it through commenting out many sections of code, I've managed to conclude that creating jQuery dialogs are the culprit. This is all done in auto.js directly after the page loads.

To help you understand better, this is the relevant code that's pointing to the problem.

function onPageLoad() {
   updateAllFieldVariableLists();
   createDialog();
   createColourDialog();
   createComboBoxOptionsDialog();
   loadDataIntoBlockIfEditing();
   $(document).on("click", function() {
      $("#neatly_clustered_map_icon_select_container").css("visibility", "hidden");
   });
   addIconsColumn("icons_tab_icons_table", true);
   updateColourPreviewDisplays();
}
function createDialog() {
   $("#time-slots-form").dialog("destroy");
   $("#time-slots-form").dialog({



Also, I tried destroying any existing dialogs before creating new ones, but this hasn't made a difference.

It seems likely that this problem happens due to the "edit" dialog using the same jQuery UI, but this doesn't seem right since my dialog id's are different.

If anyone can see what's going wrong or if you know a better solution then I'd very much appreciate your help.

 
JohntheFish replied on at Permalink Reply
JohntheFish
A few ideas, not solutions and none are absolute:

When a dialog is closed, all its markup is also destroyed, possibly including scripts. If its an edit dialog, c5 may think its still there and be waiting for the close to complete, hence the spinner.

If you have a complex dialog, break it up into tabs rather than additional popups.

Use the free spectrum picker addon and get rid of the need for the rgba sliders dialog.

With multiple dialogs, the validation tokens can get confused, so I always use just one token common to all dialogs that could be loaded from a page.
dsfgwegerhreh replied on at Permalink Reply 1 Attachment
Hi John,

Thanks for your response. That colour picker addon is certainly better than the sliders. I didn't even know it existed so I'm pleased you knew and I'll modify it. Unfortunately though, the dialog will still need to exist in some form since it's got lots of styling like borders, padding, colours and so on, and applies to many items in my dialog when clicking on it to edit the style. I've attached a screenshot to give you a better idea on what I'm doing and why having a separate tab for this is not ideal.

What do you mean by "the spinner" by the way? I think I know now. That spinning circle "hourglass" thing. It's strange though that it's always when directly after refreshing the page though and seems to disappear on or after adding a block.

Thanks anyway.