Skip to content
This repository
Browse code

Merge pull request #285 from ryanwachtl/bug-8032-multiple-urlsegment-…

…fields

Prevent conflict when using more than one SiteTreeURLSegmentField in a CMS edit form
  • Loading branch information...
commit fbfc939fc4c26fbddf53579a8c25d487a7a72458 2 parents 00097a5 + b4c9c18
Ingo Schommer authored

Showing 1 changed file with 9 additions and 9 deletions. Show diff stats Hide diff stats

  1. 18  javascript/CMSMain.EditForm.js
18  javascript/CMSMain.EditForm.js
@@ -27,20 +27,19 @@
27 27
 
28 28
 				self.data('OrigVal', self.val());
29 29
 				
30  
-				var form = self.parents('form');
31  
-				var url_segment = $('.field.urlsegment', form).find(':text');
32  
-				var live_link = $('input[name=LiveLink]', form);
33  
-				
34  
-				self._addActions();
  30
+				var form = self.closest('form');
  31
+				var urlSegmentInput = $('input:text[name=URLSegment]', form);
  32
+				var liveLinkInput = $('input[name=LiveLink]', form);
35 33
 
36  
-				if(url_segment.length > 0) {
  34
+				if (urlSegmentInput.length > 0) {
  35
+					self._addActions();
37 36
 					this.bind('change', function(e) {
38 37
 						var origTitle = self.data('OrigVal');
39 38
 						var title = self.val();
40 39
 						self.data('OrigVal', title);
41 40
 
42 41
 						// Criteria for defining a "new" page
43  
-						if ((url_segment.val().indexOf('new') == 0) && live_link.val() == '') {
  42
+						if ((urlSegmentInput.val().indexOf('new') == 0) && liveLinkInput.val() == '') {
44 43
 							self.updateURLSegment(title);
45 44
 						} else {
46 45
 							$('.update', self.parent()).show();
@@ -83,9 +82,10 @@
83 82
 			 * (String) title
84 83
 			 */
85 84
 			updateURLSegment: function(title) {
86  
-				var url_segment_field = $('.field.urlsegment', this.parents('form'));
  85
+				var urlSegmentInput = $('input:text[name=URLSegment]', this.closest('form'));
  86
+				var urlSegmentField = urlSegmentInput.closest('.field.urlsegment');
87 87
 				var updateURLFromTitle = $('.update', this.parent());
88  
-				url_segment_field.update(title);
  88
+				urlSegmentField.update(title);
89 89
 				if (updateURLFromTitle.is(':visible')) {
90 90
 					updateURLFromTitle.hide();
91 91
 				}

0 notes on commit fbfc939

Please sign in to comment.
Something went wrong with that request. Please try again.