:confirm dont work

hi i have a link in a view to delete a user: <td><%= link_to 'Destroy', {:controller => :users, :action => :destroy, :id => user}, :confirm => 'are you sure !' %></td>

all works good,when i click to delete user its ok, just i dont have the alert 'are you sure !'

i dont know why! please can you help me. thanks

Adel Mediouni <mediouni.adel@...> writes:

hi i have a link in a view to delete a user: <td><%= link_to 'Destroy', {:controller => :users, :action => :destroy, :id => user}, :confirm => 'are you sure !' %></td>

all works good,when i click to delete user its ok, just i dont have

Do you have the javacript libraries loaded?

Hi!

I’m new to Rails and on the list, but I’ll try to help.

I think you should write:

<%= link_to 'Destroy', {:controller => :users, :action

=> :destroy, :id => user, :confirm => ‘are you sure !’ } %>

…I think you should change the curly braces.

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

Everaldo

i load all js.

i try it, always the same probleme :s

However you need to have the default js libraries that were installed when you created the project in the first place. If you have removed any of controls.js, dragdrop.js, effects.js or prototype.js then it might not work. What is the contents of you public/javascript directory?

/public/javascripts/active_scaffold

/public/javascripts/codebase

/public/javascripts/vendor

/public/javascripts/widgets

/public/javascripts/apiconsole.js

/public/javascripts/application.js

/public/javascripts/aspect-contacts.js

/public/javascripts/aspect-edit.js

/public/javascripts/aspect-edit-pane.js

/public/javascripts/aspect-filters.js

/public/javascripts/contact-list.js

/public/javascripts/custom-mobile-scripting.js

/public/javascripts/diaspora.js

/public/javascripts/fileuploader-custom.js

/public/javascripts/friend-finder.js

/public/javascripts/ie.js

/public/javascripts/inbox.js

/public/javascripts/infinite_scroll.js

/public/javascripts/jquery.autocomplete-custom.js

/public/javascripts/jquery.js

/public/javascripts/keycodes.js

/public/javascripts/menu.js

/public/javascripts/mobile.js

/public/javascripts/photo-show.js

/public/javascripts/prototype.js

/public/javascripts/publisher.js

/public/javascripts/rails.js

/public/javascripts/search.js

/public/javascripts/sorttable.js

/public/javascripts/stream.js

/public/javascripts/validation.js

/public/javascripts/view.js

/public/javascripts/web-socket-receiver.js

Ok you have pretty much everything and the kitchen sink in there. This is what *might* be happening. I have found that jquery and prototype conflict and have had to handle this with my own code. Well for us jquery and prototype were conflicting, it could be for you as well.

// We are using jQuery which does not support the :confirm => '...' option of the // link_to and button_to tags. However if we also load the prototype js library // things seem to go wrong with the existing js code so we have to handle this

function delete_record(message) {     var r = confirm("Do you want to delete " + message + "?");

    return r; }

and you use it with

<%= link_to 'Delete this race', race_delete_url(:id => race.id), :onclick => "return delete_record(\"#{race.display_name}\");" %>

This should at least get you out of the hole. However mixing javascript libraries is not a good idea.

i dont like kitchen :stuck_out_tongue: so to mix is not realy my hobbie :smiley: i try to develop an applcation based on the project Diaspora, so i’m adding some views and controller in the diaspora project.

its why i have all these lib.

any way, im going to try your soulution. and thanks over all.

Also install the Firebug addin to Firefox and try it. Firebug will give you information about javascript errors.

Colin

hi,

try

<%= link_to 'Destroy, user_path(@user), :method=>:delete, :confirm =>'are you sure?'%>

tom