Jquery quickly creates a drag-and-drop shopping cart DragDrop_jquery

Source: Internet
Author: User
The drag function has already become a highlight of attracting users from various websites. Have you ever wondered how to apply the drag function to the shopping cart function module of e-commerce websites? In this way, the buyer only needs to drag the item he or she is interested in to his or her own shopping cart. He or she can also delete the item from the shopping cart and update the overall price and quantity of the shopping cart.
Let's start with the instance. This instance does not connect to the database to read data to initialize Products. Instead, it creates some virtual Products as follows:
1. Create a Product entity class

The Code is as follows:


Public class Product
{
Public string Code {get; set ;}
Public string Name {get; set ;}
Public string Description {get; set ;}
Public double Price {get; set ;}
}
[Code]
2. Create a product List
[Code]
Public class Product
{
Public string Code {get; set ;}
Public string Name {get; set ;}
Public string Description {get; set ;}
Public double Price {get; set ;}
}


3. Create a DataList and bind the List

The Code is as follows:


RepeatDirection = "Horizontal" runat = "server">

Code = '<% # Eval ("Code") %>' id = 'item _ <%# Container. ItemIndex + 1%> '>


  • <% # Eval ("Code") %>


  • <% # Eval ("Name") %>


  • <% # Eval ("Description") %>


  • $ <% # Eval ("Price") %>




  • Private void BindData ()
    {
    Var products = GetProducts ();
    DlProducts. DataSource = products;
    DlProducts. DataBind ();
    }


    ProductItemStyle style name
    Container. ItemIndex dynamically generates consecutive item numbers

    4. Generate Products Div Draggable
    Download the latest Jquery JS file and Its UI file:

    The Code is as follows:


    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.