You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by hese <10...@gmail.com> on 2012/01/31 16:58:49 UTC

problems getting rid of the JS confirm box from confirm mixin

Hi,

I am trying to modify the confirm mixin in this example to remove the ugly
javscript confirm() dialog box, and instead use a jQuery based dialog.

http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/componentscrud/persons

Problem:
Orignal code does this - Confirm.js
if (!confirm(this.message)) {
   e.stop();
}

So, the code waits for user input.  If no is clicked, the post event is
stopped, else the event continues do proceed as usual.  This cannot be done
in custom made dialog boxes, because it is not possible to wait for user
input like the confirm() method does.

My mixin JS code:
// stop the event
e.stop();
//store the href so I can post it myself if yes is clicked
var href = jQuery('#'+this.elementId).attr("href"); 
// my custom method to create a jQuery dialog box
createConfirmationDialog(this.message, {
			yesLabel: 'Delete it',
			noLabel: 'Cancel',
			yesHandler: doDelete // this method will post the form to href stored
earlier on 'yes'
		});

All is good till here.  Now that I took over the posting from tapestry, how
do I handle displaying the results?  The post response is a zone update. 
What method tapestry JS methods should I pass the response to in order to
refresh the zone?

Thanks!




















--
View this message in context: http://tapestry.1045711.n5.nabble.com/problems-getting-rid-of-the-JS-confirm-box-from-confirm-mixin-tp5444911p5444911.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: problems getting rid of the JS confirm box from confirm mixin

Posted by hese <10...@gmail.com>.
I think I might have my solution from here -

http://code.google.com/p/flowlogix/source/browse/tapestry-services/src/main/resources/com/flowlogix/web/mixins/DisableAfterSubmit.js?r=caa40702061eee198cf2f82dfd48106e34316fce



--
View this message in context: http://tapestry.1045711.n5.nabble.com/problems-getting-rid-of-the-JS-confirm-box-from-confirm-mixin-tp5444911p5451126.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: problems getting rid of the JS confirm box from confirm mixin

Posted by hese <10...@gmail.com>.
Solution:

// stop the event 
e.stop(); 

//store the href so I can post it myself if yes is clicked 
var href = jQuery('#'+this.elementId).attr("href"); 

// store the zone so we can update that later
//zone id is passed into the mixin as a param
var zoneManager =  Tapestry.findZoneManagerForZone(this.zoneId); 

// my custom method to create a jQuery dialog box 
createConfirmationDialog(this.message, { 
        yesLabel: 'Delete it', 
        noLabel: 'Cancel', 
        yesHandler: doDelete // this method will post the form to href
stored earlier on 'yes' 
}); 

// doDelete handler
var doDelete = function() { 
        	new Ajax.Request(href, {
                method: 'post',
    			onFailure: function(t)
                {
                    alert('Error communication with the server: ' +
t.responseText.stripTags());
                },
                onException: function(t, exception)
                {
                    alert('Error communication with the server: ' +
exception.message);
                },
                onSuccess: function(t)
                {
                	// use the reponse to update the zone.
                	zoneManager.processReply(t.responseJSON);
    	        }.bind(this)
            });
    	};

--
View this message in context: http://tapestry.1045711.n5.nabble.com/problems-getting-rid-of-the-JS-confirm-box-from-confirm-mixin-tp5444911p5455340.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: problems getting rid of the JS confirm box from confirm mixin

Posted by hese <10...@gmail.com>.
No answers?? :(( Please help!


--
View this message in context: http://tapestry.1045711.n5.nabble.com/problems-getting-rid-of-the-JS-confirm-box-from-confirm-mixin-tp5444911p5450938.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org