Skip to content

Commit 4696b1b

Browse files
committed
New Bibledit kernel with bug fixes
bibledit/cloud#1054
1 parent 8bc2d64 commit 4696b1b

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

server/dialog/select.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ std::string ajax(const Settings& settings)
7373
create_select (document, settings);
7474

7575
// The Javascript to POST the selected value if it changes.
76+
// The script should be a module because that defers execution till the document has been loaded.
7677
std::string javascript = filter_url_file_get_contents(filter_url_create_root_path({"dialog/selectajax.js"}));
7778
javascript = remove_comment_from_code (std::move(javascript));
7879
javascript = filter::strings::replace("identification", settings.identification, std::move(javascript));
7980

8081
pugi::xml_node script_node = document.append_child("script");
82+
script_node.append_attribute("type") = "module";
8183
script_node.text().set(javascript.c_str());
8284

8385
// Convert it to html including Javascript.
@@ -119,11 +121,13 @@ std::string form(const Settings& settings, const Form& form)
119121
}
120122

121123
// If automatic submit, add a script that does the job.
124+
// The script should be a module because that defers execution till the document has been loaded.
122125
if (form.auto_submit) {
123126
std::string javascript = filter_url_file_get_contents(filter_url_create_root_path({"dialog/selectform.js"}));
124127
javascript = remove_comment_from_code (std::move(javascript));
125128
javascript = filter::strings::replace("identification", settings.identification, std::move(javascript));
126129
pugi::xml_node script_node = document.append_child("script");
130+
script_node.append_attribute("type") = "module";
127131
script_node.text().set(javascript.c_str());
128132
}
129133

server/dialog/selectform.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ along with this program; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1717
*/
1818

19-
document.querySelector("#identification").addEventListener("change",function(){
20-
document.getElementById("identification").parentElement.submit();
19+
document.addEventListener("DOMContentLoaded", function() {
20+
const identification = document.querySelector("#identification");
21+
identification.addEventListener("change",function(event){
22+
document.querySelector("#identification").parentElement.submit();
23+
});
2124
});

server/edit/index.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ std::string edit_index (Webserver_Request& webserver_request)
7777

7878
// Get the active Bible, and check whether the user has access to it.
7979
// And if the user has used a query to preset the active Bible, get that preset Bible.
80-
// Set the chosen Bible on the option HTML tag.
80+
// Store the active Bible in the HTML.
8181
std::string bible = access_bible::clamp (webserver_request, webserver_request.database_config_user()->get_bible ());
8282
if (webserver_request.query.count ("bible"))
8383
bible = access_bible::clamp (webserver_request, webserver_request.query ["bible"]);
@@ -108,7 +108,6 @@ std::string edit_index (Webserver_Request& webserver_request)
108108
.selected = bible,
109109
};
110110
dialog::select::Form form { .auto_submit = true };
111-
//view.set_variable(identification, dialog::select::ajax(settings));
112111
view.set_variable(identification, dialog::select::form(settings, form));
113112
}
114113

0 commit comments

Comments
 (0)