简体   繁体   中英

Foundation, modal and Rails: event.returnValue is deprecated

I'm been using the Railsapp project to get excellent start on this project and this is the first time I'm using Foundation to help me with the front end.

Their User Management uses the following code in its view to display users.

   <% @users.each do |user| %>
   <tr>
    <td><%= link_to user.name, user %></td>
    <td><%= user.email %></td>
    <td><%= user.created_at.to_date %></td>
    <td><%= user.roles.first.name.titleize unless user.roles.first.nil? %></td>
    <td>
      <a data-toggle="modal" href="#role-options-<%= user.id %>" class="btn btn-mini" type="button">Change role</a>
      <%= render user %>
    </td>
    <td><%= link_to("Delete user", user_path(user), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'btn btn-mini') unless user == current_user %></td>
</tr>

This seems very straightforward as a modal is launched to allow the user to change the Role of the selected user. But when I click the "Change Role" link, nothing happens as if javascript wasn't installed. The server logs report no activity either.

I get this error in Console:

 event.returnValue is deprecated. Please use the standard event.preventDefault() instead. 

Clearly, javascript is running and I can see it is being used for other functions, like warning messages for "Delete User". I've googled the error message and all I've seen is that it's a warning, that's all. But I'm not seeing how to get past this issue.

This is my application.js

 //= require jquery
 //= require jquery_ujs
 // Note: Foundation 5 won't work with turbolinks
 //= require foundation
 //= require_tree .
 $(function() {
   $(document).foundation();
 });

Other troubleshooting steps is to google other railsapps issues wiki, set up other railsapps starters with different settings. I find that Foundation 4 yields the same result while the modal works with Twitter Bootstrap, but my requirements are for Foundation. Set the href to just "*". I am running this on an XP machine and have gotten the same results in a OS X machine. Both Chrome, MSIE and Firefox show the same dead link, both on Windows and OS X. I see no issues specific to this on the RailsApps github wiki and am not confident this is an error in their code.

What am I overlooking in javascript that I'm not seeing? thanx, sam

Sorry to say (after all your trouble) but simply, the modal was written for Bootstrap and hasn't yet been updated to accommodate Foundation. See https://github.com/RailsApps/rails_apps_composer/issues/261

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM