Save Button to Save all Modules in Page Include

I have 2 pages, a main page and a sub-page that is connected to the main page with a Page Include component.  Is there a way that I can add a button to the main page that will be able to save the modules from the sub-page?

Yup. Setup the Save action on a local model and hack the name of the model in the page include into it via the XML.

thanks Pat - i’ve tried that, but i must be doing something wrong… the name of the model in the Page Include is “rfqCentral”… do i need to write is a certain way?

<action type="save"> <models> <model>rfqCentral</model> </models> <onerroractions> <action type="blockUI" message="There was an error saving" timeout="3000"/> </onerroractions> </action>

yea… tried that and its not working… thanks anyway…

Wait. The page include has to be open, otherwise it won’t work.

when i try this, i get an error at the top of the page that says the model cannot be found…

strange. this has worked for me.

Although I didn’t get the error Scott describes, I was having issues with this as well when hackifying the standard save/cancel button. I was able to get this to work when I moved the save action into a multiple action framework action.

Correct, use multiple actions and have the same model structure (names/fields) in all pages.

We use this:

&#47;&#47; Global Save Buttons Javascript<br />(function (skuid){<br />&#47;&#47; NOTE: Requires a ui-only Model named ChangeTracker&nbsp;<br />&#47;&#47; Do not load on pageload, 0 rows, create row if none,<br />&#47;&#47; Do not prevent leaving with unsaved changes,<br />&#47;&#47; &nbsp; &nbsp; &nbsp;And a ui-only checkbox field called ModelChanges&#46;<br />&#47;&#47; Set global buttons to run snippets<br />&#47;&#47; "saveAllSnippet' and 'cancelAllSnippet' <br />&#47;&#47; &nbsp; and conditionally enable when ModelChanges is true&#46;<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />&#47;&#47; Shortcuts &amp; Global Variables &#47;&#47;<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />var $ = skuid&#46;$,<br /> $e = skuid&#46;events&#46;subscribe,<br /> ChangeTracker;<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />&#47;&#47; Helper Functions &#47;&#47;<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />var checkForChanges = function(){<br /> if (!ChangeTracker) ChangeTracker = skuid&#46;$M('ChangeTracker');<br /> var trackerRow = ChangeTracker &amp;&amp; ChangeTracker&#46;getFirstRow();<br /> if (trackerRow) {<br /> var changes = false;<br /> $&#46;each(skuid&#46;model&#46;map(),function(){<br /> if (this&#46;hasChanged &amp;&amp; this&#46;preventUnloadIfUnsavedChanges &amp;&amp; (this&#46;id !== 'ChangeTracker')) {<br /> changes = true;<br /> }<br /> });<br /> ChangeTracker&#46;updateRow(trackerRow, {'ModelChanges': changes});<br /> }<br />};<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />&#47;&#47; Subscriptions &#47;&#47;<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />$e('models&#46;cancelled', checkForChanges);<br />$e('models&#46;saved', checkForChanges);<br />$e('row&#46;created', checkForChanges);<br />$e('row&#46;updated', checkForChanges);<br />$e('row&#46;deleted', checkForChanges);<br />$e('row&#46;undeleted', checkForChanges);<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />&#47;&#47; &nbsp; &nbsp;Pageload &#47;&#47;<br />&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;&#47;<br />$(document&#46;body)&#46;one('pageload',function(){<br /> ChangeTracker = skuid&#46;$M('ChangeTracker');<br />}); <br />})(skuid);


And here are the snippets:

'saveAllSnippet': function () { var modelsToSave = [],<br />modelsToExclude = ['AddTests','ProcessLog','ChangeTracker','ShowTabs','UI_Model','DefaultTo','ChartAudit'],<br />dfd = new $&#46;Deferred();<br />$&#46;each(skuid&#46;model&#46;map(), function(){<br />if (this&#46;hasChanged &amp;&amp; (modelsToExclude&#46;indexOf(this&#46;id) === -1) &amp;&amp; this&#46;preventUnloadIfUnsavedChanges) {<br />modelsToSave&#46;push(this);<br />}<br />});<br />$&#46;when(skuid&#46;model&#46;save(modelsToSave))<br />&#46;done(function(result){<br />console&#46;log('All Models Saved&#46;');<br />dfd&#46;resolve(result);<br />})<br />&#46;fail(function(result){<br />console&#46;log('All Model Save Failed&#46;');<br />dfd&#46;reject(result);<br />});<br />return dfd&#46;promise();<br />},<br />'cancelAllSnippet': function(){<br />var modelsToCancel = [];<br />$&#46;each(skuid&#46;model&#46;map(), function(){<br />if (this&#46;hasChanged &amp;&amp; this&#46;preventUnloadIfUnsavedChanges) {<br />modelsToCancel&#46;push(this);<br />}<br />});<br />skuid&#46;model&#46;cancel(modelsToCancel);<br />}

Quite cool. I think this wouldn’t work if you have the same page include on a host page more than once since the earlier model objects get dropped off the page when the latest page-include of a given skuid page has loaded.

Right. You can only use a page include once per page.