Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
jquery-dragsort-rails
Advanced tools
jQuery DragSort Plugin is a list drag and sort plugin made available by and on CodePlex. jQuery List Drag Sort features list element's dragging, dropping, and saving the sorted list by user using jQuery.
jquery-dragsort-rails is a library that integrates jQuery List Drag Sort for Rails 3.1 or above Asset Pipeline.
Add this in your Gemfile:
gem "jquery-dragsort-rails"
To use this plugin follow these steps:
Require jquery-dragsort in your app/assets/application.js file.
//= require jquery-dragsort
Let's assume you are sorting products on your page, and your code looks something like this in your sort_products.html.erb template -
<%= form_tag save_order_products_path do -%>
<!-- save sort order here which can be retrieved from server on postback -->
<input id= "product_positions" name="product_positions" type="hidden" value="0" />
<div class="span2" id="save_order"></div><!-- To insert a button when list's position is changed. -->
<% end -%>
<ul id="products" class="thumbnails">
<% @products.each do |product| %>
<% unless product.pictures.blank? %>
<%= content_tag_for :li, product, :class=> "span2" do %>
<div class="span2 thumbnail" value="<%= product.id %>">
<%= image_tag(product.pictures.first.image(:small), :size => "260x180") %>
<div class="caption">
<h5><%= product.name %></h5>
<p><%= product.sku_code %></p>
<p><%= truncate(product.description, :length => 45, :separator => ' ') %></p>
</div>
</div>
<% end %>
<% end %>
<% end %>
</ul>
In your products.js.cofee file -
saveOrder = ->
data = $("#products li").map ->
$(this).children().attr("value")
.get()
$("input[name=product_positions]").val data.join(",")
$("#save_order").html '<button class="btn btn-primary"><i class="icon-ok icon-white"></i> Save</button>'
$("#products, #list2").dragsort
dragSelector: "div"
dragBetween: true
dragEnd: saveOrder
placeHolderTemplate: "<li class='placeHolder'><div></div></li>"
Thanks to Codeplex for making list dragsort plugin available.
This project is released under and uses MIT-LICENSE. Go to http://dragsort.codeplex.com/license for more licensing infromation.
FAQs
Unknown package
We found that jquery-dragsort-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.