Dynamically changing the editor modal title
Dynamically changing the editor modal title
Hi,
I'm trying to dynamically change the title of the editor modal, similar to this, but am finding that the title of the modal stays on it's default value.
I've written the following delegated jQuery on click function to handle the title change as I want the title to change depending on the selected row and it is picking up the correct text when you click on the row, it just seems that the last bit is failing.
$("#vehicle-list").on('click', 'tbody tr', function() {
var selected_vehicle = $(this).children('td:first-child').text()+' '+$(this).children('td:nth-child(2)').html();
console.log(selected_vehicle);
editor.on( 'initEdit', function (selected_vehicle) {
editor.title(selected_vehicle);
});
});
editor
is a global variable, and after triggering the function and launching an edit modal, editor.title()
returns an empty string from the console.
I have also tried this form of the above function:
$("#vehicle-list").on('click', 'tbody tr', function() {
var selected_vehicle = $(this).children('td:first-child').text()+' '+$(this).children('td:nth-child(2)').html();
console.log(selected_vehicle);
editor.title(selected_vehicle);
});
which does give me the expected string when I type editor.title()
into the console, but doesn't modify the modal's title.
Am I trying something I can't do, or am I missing something?
Answers
Additional:
After calling up the edit modal,
editor.title()
returns the default title in the console, and it stays like that after the modal is closed.