| |
Low Pro |
I changed the auth code as follows but cannot figure out any way to
var AJ =
authenticity_token_query_parameter_for_page:function()
Remote.Delete = Behavior.create( Remote.Base,
this._makeRequest( options );
On 25 Jan, 00:25, Jarkko Laine <jar...@jlaine.net> wrote:
> > I have added the following that now works, except for the reload which
> > var AJ =
> Can't answer to your reload question off the top of my head, but you
> > document.body.select( 'input[ name = "authenticity_token" ]' )
> This is also same as $$('input[name="authenticity_token']).first() (http://prototypejs.org/api/utility/dollar-dollar
> --
furthur simplify.
{
encode_authenticity_token:function( token )
{
return encodeURIComponent( $F(token) )
},
{
return 'authenticity_token=' + AJ.encode_authenticity_token(
$$( 'input[ name = "authenticity_token" ]' ).first() )
}
work. The javascript now looks as follows:
{
onclick: function( event )
{
var element = Event.element( event );
if ( element.hasClassName( 'delete_link' ) )
{
if ( confirm( 'Are you sure?' ) )
{
var options =
{
url: element.href.gsub( '/delete$', '' ),
method: 'delete',
parameters:
AJ.authenticity_token_query_parameter_for_page()
};
options = Object.extend( options, this.options );
}
return false;
}
return true;
}
{
'#item_list' : Remote.Delete
item_list. If the element that received the click has a classname of
delete_link, then a confirmation will be displayed and the element
deleted through the destroy method.
> > does not appear to be working as I intended. For completeness, I have
> > included my updated delete method.
> > {
> > encode_authenticity_token:function( token )
> > {
> > return encodeURIComponent( $(token).value )
> can replace $(token).value with $F(token) (seehttp://prototypejs.org/api/utility/dollar-f)
> > [ 0 ] )
> ). If you give the input field an id, it can be reduced to $
> ('authenticity_token').
> Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce....