mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUG: Prevent conflict when using multiple SiteTreeURLSegmentField's in CMS edit form
This commit is contained in:
parent
00097a5d5d
commit
b4c9c18b33
@ -27,20 +27,19 @@
|
||||
|
||||
self.data('OrigVal', self.val());
|
||||
|
||||
var form = self.parents('form');
|
||||
var url_segment = $('.field.urlsegment', form).find(':text');
|
||||
var live_link = $('input[name=LiveLink]', form);
|
||||
|
||||
self._addActions();
|
||||
var form = self.closest('form');
|
||||
var urlSegmentInput = $('input:text[name=URLSegment]', form);
|
||||
var liveLinkInput = $('input[name=LiveLink]', form);
|
||||
|
||||
if(url_segment.length > 0) {
|
||||
if (urlSegmentInput.length > 0) {
|
||||
self._addActions();
|
||||
this.bind('change', function(e) {
|
||||
var origTitle = self.data('OrigVal');
|
||||
var title = self.val();
|
||||
self.data('OrigVal', title);
|
||||
|
||||
// Criteria for defining a "new" page
|
||||
if ((url_segment.val().indexOf('new') == 0) && live_link.val() == '') {
|
||||
if ((urlSegmentInput.val().indexOf('new') == 0) && liveLinkInput.val() == '') {
|
||||
self.updateURLSegment(title);
|
||||
} else {
|
||||
$('.update', self.parent()).show();
|
||||
@ -83,9 +82,10 @@
|
||||
* (String) title
|
||||
*/
|
||||
updateURLSegment: function(title) {
|
||||
var url_segment_field = $('.field.urlsegment', this.parents('form'));
|
||||
var urlSegmentInput = $('input:text[name=URLSegment]', this.closest('form'));
|
||||
var urlSegmentField = urlSegmentInput.closest('.field.urlsegment');
|
||||
var updateURLFromTitle = $('.update', this.parent());
|
||||
url_segment_field.update(title);
|
||||
urlSegmentField.update(title);
|
||||
if (updateURLFromTitle.is(':visible')) {
|
||||
updateURLFromTitle.hide();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user