mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
#1485 Changing the name of a group results in javascript error
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43880 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
dc1775169d
commit
ea4c77c366
@ -4,24 +4,22 @@ Behaviour.register({
|
|||||||
* Get the URL segment to suggest a new field
|
* Get the URL segment to suggest a new field
|
||||||
*/
|
*/
|
||||||
onchange: function() {
|
onchange: function() {
|
||||||
if( this.value.length == 0 )
|
if(this.value.length == 0) return;
|
||||||
return;
|
if(!$('Form_EditForm_URLSegment')) return;
|
||||||
|
|
||||||
var urlSegmentField = $('Form_EditForm_URLSegment');
|
var urlSegmentField = $('Form_EditForm_URLSegment');
|
||||||
|
|
||||||
var newSuggestion = urlSegmentField.suggestNewValue( this.value.toLowerCase() );
|
var newSuggestion = urlSegmentField.suggestNewValue( this.value.toLowerCase() );
|
||||||
|
|
||||||
var isNew = $('Form_EditForm_ID').value.indexOf("new") == 0;
|
var isNew = $('Form_EditForm_ID').value.indexOf("new") == 0;
|
||||||
|
|
||||||
if( newSuggestion == urlSegmentField.value || isNew || confirm( 'Would you like me to change the URL to:\n\n' + newSuggestion + '/\n\nClick Ok to change the URL, click Cancel to leave it as:\n\n' + urlSegmentField.value ) )
|
if( newSuggestion == urlSegmentField.value || isNew || confirm( 'Would you like me to change the URL to:\n\n' + newSuggestion + '/\n\nClick Ok to change the URL, click Cancel to leave it as:\n\n' + urlSegmentField.value ) )
|
||||||
urlSegmentField.value = newSuggestion;
|
urlSegmentField.value = newSuggestion;
|
||||||
// If you type in Page name, the Navigation Label and Meta Title should automatically update the first time
|
// If you type in Page name, the Navigation Label and Meta Title should automatically update the first time
|
||||||
// @todo: Change file name from UpdateURL to something more geneneric since we now do more than update the URL.
|
// @todo: Change file name from UpdateURL to something more geneneric since we now do more than update the URL.
|
||||||
if( $('Form_EditForm_MenuTitle').value.indexOf("New") == 0 ) {
|
if($('Form_EditForm_MetaTitle') && $('Form_EditForm_MenuTitle').value.indexOf("New") == 0 ) {
|
||||||
$('Form_EditForm_MenuTitle').value = this.value;
|
$('Form_EditForm_MenuTitle').value = this.value;
|
||||||
}
|
}
|
||||||
// @todo see if updating this is confusing (Q: why isn't my page title changing? A: Check the Meta-Data tab)
|
// @todo see if updating this is confusing (Q: why isn't my page title changing? A: Check the Meta-Data tab)
|
||||||
if( $('Form_EditForm_MetaTitle').value.length == 0 ) {
|
if($('Form_EditForm_MetaTitle') && $('Form_EditForm_MetaTitle').value.length == 0 ) {
|
||||||
$('Form_EditForm_MetaTitle').value = this.value;
|
$('Form_EditForm_MetaTitle').value = this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user