[Seaside] Submiting a form with a confirmation dialog (jquery) does not work properly

Esteban Lorenzano estebanlm at gmail.com
Wed Mar 16 22:27:10 UTC 2011


Hi, 
I'm trying to add a "confirmation dialog" using jQuery in a form, and calling submit from a jquery statement is not working properly (or at least, is not working as I was hoping to work). If I submit the form using javascript, I was expecting #defaultAction: to be called, but no :( 

Does anybody knows how can I do this properly? 

In the example, I render a dialog (with a form), then a form, and the "accept" button opens the dialog. The accept button in the dialog triggers my confirmation dialog and on complete submits the original form. 

This is the code: 

renderDialogCollectExtraInfoOn: html
	| dialogId formId dialogFormId |

	dialogId := html nextId.
	dialogFormId := html nextId.	 
	formId := html nextId.
	
	html heading 
		level2;
		with: 'Collect extra information in confirmation dialog'.
	
	html div
		id: dialogId;  
		script: (html jQuery this dialog
			title: 'Dialog with extra info';
			resizable: false;
			modal: true;
			autoOpen: false;
			addButton: 'Accept' do: (html jQuery ajax 
				serializeForm: (html jQuery id: dialogFormId);
				onComplete: ((html jQuery id: formId) call: 'submit'));
			addButton: 'Cancel' do: (html jQuery this dialog close));
		with: [
			html form
				id: dialogFormId;
				with: [ 
					html checkbox 
						on: #confirm1 of: self;
						with: 'Confirm 1' ] ].
	
	html form
		id: formId;
		defaultAction: [ self halt. self inform: 'Ok'. "I'm expecting this to be executed" ];
		with: [		
			html text: 'Some text: '.
			html textInput on: #text of: self.

			html button 
				onClick: (html javascript
					add: ((html jQuery id: dialogId) dialog open);
					add: (JSStream on: 'return false');
					yourself);
				callback: [ self halt. "I'm not expecting this to be executed" ];
				with: 'Accept' ] 

Thanks, 
Esteban


More information about the seaside mailing list