Skip to content
This repository
Browse code

MINOR Removed $('.cms-content').loadForm(), its very similar to loadP…

…anel() - accepts callbacks, but that's not specific to forms. Listen to 'afterstatechange' rather than 'loadform' events
  • Loading branch information...
commit e2df1f4c5f1c5983f1349419c1f1c177f180620d 1 parent b025b95
Ingo Schommer authored
2  admin/javascript/LeftAndMain.AddForm.js
@@ -89,7 +89,7 @@
89 89
 				data.push({name:button.attr('name'),value:button.val()});
90 90
 
91 91
 				// TODO Should be set by hiddenfield already
92  
-				jQuery('.cms-content').entwine('ss').loadForm(
  92
+				jQuery('.cms-content').entwine('ss').submitForm(
93 93
 					this.attr('action'),
94 94
 					null,
95 95
 					function() {
72  admin/javascript/LeftAndMain.Content.js
@@ -27,78 +27,6 @@
27 27
 			},
28 28
 			
29 29
 			/**
30  
-			 * Function: loadForm
31  
-			 * 
32  
-			 * See $('.cms-container').loadPanel() on a frequently used alternative
33  
-			 * to direct ajax loading of content, with support for the window.History object.
34  
-			 * 
35  
-			 * Parameters:
36  
-			 *  (String) url - ..
37  
-			 *  (Function) callback - (Optional) Called after the form content as been loaded
38  
-			 *  (Object) ajaxOptions - Object literal merged into the jQuery.ajax() call (Optional)
39  
-			 * 
40  
-			 * Returns:
41  
-			 *  (XMLHTTPRequest)
42  
-			 */
43  
-			loadForm: function(url, form, callback, ajaxOptions) {
44  
-				var self = this;
45  
-				if(!form || !form.length) {
46  
-					var form = $('.cms-content-fields form:first', self);
47  
-					if(form.length == 0) form = $('.cms-content-fields').parents("form").eq(0);
48  
-				}
49  
-
50  
-				// Alert when unsaved changes are present
51  
-				if(!form.confirmUnsavedChanges()) return false;
52  
-			
53  
-				// hide existing form - shown again through _loadResponse()
54  
-				form.addClass('loading');
55  
-
56  
-				this.trigger('loadform', {form: form, url: url});
57  
-			
58  
-				var opts = jQuery.extend({}, {
59  
-					// Ensure that form view is loaded (rather than whole "Content" template)
60  
-					headers: {"X-Pjax" : "CurrentForm"},
61  
-					url: url, 
62  
-					complete: function(xmlhttp, status) {
63  
-						self.loadForm_responseHandler(form, xmlhttp.responseText, status, xmlhttp);
64  
-						if(callback) callback.apply(self, arguments);
65  
-					}, 
66  
-					dataType: 'html'
67  
-				}, ajaxOptions);
68  
-
69  
-				return jQuery.ajax(opts);
70  
-			},
71  
-			
72  
-			/**
73  
-			 * Function: loadForm_responseHandler
74  
-			 *
75  
-			 * Loads the response into the DOM provided. Assumes oldForm is contains
76  
-			 * the form tag to replace. If oldForm isn't present in the DOM, such as
77  
-			 * if this form is only shown after click, append the whole form.
78  
-			 *
79  
-			 * Parameters:
80  
-			 *  (String) oldForm - HTML or eval'd javascript
81  
-			 *  (String) html - HTML to replace oldForm
82  
-			 *  (String) status
83  
-			 *  (XMLHTTPRequest) xmlhttp
84  
-			 */
85  
-			loadForm_responseHandler: function(oldForm, html, status, xmlhttp) {
86  
-				if(!html) return;
87  
-
88  
-				if(oldForm.length > 0) {
89  
-					oldForm.replaceWith(html); // triggers onmatch() on form
90  
-				} else {
91  
-					 $('.cms-content').append(html);
92  
-				}
93  
-				
94  
-				// redraw the layout.
95  
-				jQuery('.cms-container').entwine('ss').redraw();
96  
-				
97  
-				// set status message based on response
98  
-				var _statusMessage = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText;
99  
-			},
100  
-			
101  
-			/**
102 30
 			 * Function: ajaxSubmit
103 31
 			 * 
104 32
 			 * Parameters:
3  admin/javascript/LeftAndMain.js
@@ -194,9 +194,6 @@ jQuery.noConflict();
194 194
 			 * For example, a ModelAdmin search event should contain the search terms
195 195
 			 * as URL parameters, and the result display should automatically appear 
196 196
 			 * if the URL is loaded without ajax.
197  
-			 * 
198  
-			 * Alternatively, you can load new content via $('.cms-content').loadForm(<url>).
199  
-			 * In this case, the action won't be recorded in the browser history.
200 197
 			 */
201 198
 			handleStateChange: function() {
202 199
 				var self = this, h = window.History, state = h.getState(); 
3  docs/en/reference/cms-architecture.md
Source Rendered
@@ -176,8 +176,7 @@ should be placed in jQuery.entinwe `onmatch()` rules which apply to the newly cr
176 176
 See `$('.cms-container').handleStateChange()` in `LeftAndMain.js` for details.
177 177
 
178 178
 Alternatively, form-related Ajax calls can be invoked through their own wrappers,
179  
-which don't cause history events and hence allow callbacks: `$('.cms-content').loadForm()`
180  
-and `$('.cms-content').submitForm()`.
  179
+which don't cause history events and hence allow callbacks: `$('.cms-content').submitForm()`.
181 180
 
182 181
 Within the PHP logic, the `[api:PjaxResponseNegotiator]` class determines which view is rendered.
183 182
 Through a custom `X-Pjax` HTTP header, the client can declare which view he's expecting,

0 notes on commit e2df1f4

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