@{
ViewBag.Title = "Easyui_draggable";
Layout = "~/Views/Shared/Layouts.cshtml";
} <style type="text/css">
.products{
overflow:auto;
height:%;
background:#fafafa;
} .products ul{
list-style:none;
margin:;
padding:;
} .products li{
display:inline;
float:left;
margin:10px;
border:1px solid #ff0000;
} .item{
display:block;
text-decoration:none;
} .item img{
width:100px;
height:100px;
} .cart {
height:1000px;
width:300px;
float:right;
} </style>
<script type="text/javascript">
$(function () {
$("#cartcontent").datagrid({
singleSelect:true,//单行选中
showFooter:true//显示页脚
});
}) $(".item").draggable({
revert: true,//如何使true,在拖动的元素会返回到其实位置
proxy: 'clone',//clone时,会复制一个元素
onStartDrag: function () {
$(this).draggable('options').cursor = 'not-allowed';
$(this).draggable('proxy').css('z-index', );
},
onStopDrag: function () {
$(this).draggable('options').cursor = 'move';
}
}); $(".cart").droppable({
onDragEnter: function (e, source) {
$(source).draggable('options').cursor = 'auto';
},
onDragLeave: function (e,source) {
$(source).draggable('options').cursor = 'not-allowed';
},
onDrop: function (e,source) {
var name = $(source).find('p:eq(0)').html();
var price = $(source).find('p:eq(1)').html();
addProduct(name,parseFloat(price.split('RMB')[]));
}
}); function addProduct(name,price) {
var dg = $("#cartcontent");
var data = dg.datagrid('getData');
function add() {
for (var i = ; i < data.total; i++) {
var row = data.rows[i];
if (row.name == name) {
row.quantity += ;
return;
}
}
data.total += ;
data.rows.push({
name: name,
quantity: ,
price:price
});
}
add();
dg.datagrid('loadData', data);
var cost = ;
var rows = dg.datagrid('getRows');
for (var i = ; i < rows.length; i++) {
cost += rows[i].price * rows[i].quantity;
}
dg.datagrid('reloadFooter', [{ name: '总计', price: cost }]);
} </script> <h2>购物车</h2>
<div class="easyui-panel" fit="true" border="false" style="height:100%;overflow:hidden">
<div class="cart">
<div class="ctitle">购物车</div>
<div style="background:#fff">
<table id="cartcontent" fitColumns="true" style="width:250px; height:auto;">
<thead>
<th field="name" width="">商品名称</th>
<th field="quantity" width="">数量</th>
<th field="price" width="">价格</th>
</thead>
</table>
</div>
<div class="ctitle" style="position:absolute;bottom:40px">把商品拖到这里添加到购物车</div>
</div>
<div class="products">
<ul>
<li>
<a href="#" class="item">
<img src="~/Iamge/1.png" />
<div>
<p>气球</p>
<p>价格:RMB25</p>
</div>
</a>
</li>
<li>
<a href="#" class="item">
<img src="~/Iamge/1.png" />
<div>
<p>气球</p>
<p>价格:RMB25</p>
</div>
</a>
</li>
<li>
<a href="#" class="item">
<img src="~/Iamge/2.png" />
<div>
<p>气球</p>
<p>价格:RMB25</p>
</div>
</a>
</li>
<li>
<a href="#" class="item">
<img src="~/Iamge/3.png" />
<div>
<p>气球</p>
<p>价格:RMB25</p>
</div>
</a>
</li>
</ul> </div> </div>

只能作参考,运行不起来。

EasyUI ---- draggable购物车的更多相关文章

  1. EasyUI实现购物车、菜单和窗口栏等最常用的用户界面功能

    一.EasyUI jQuery EasyUI 是一个基于 jQuery 的框架,集成了各种用户界面插件. easyui 提供建立现代化的具有交互性的 javascript 应用的必要的功能. 使用 e ...

  2. easyUI draggable组件使用

    easyUI draggable组件使用: <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  3. easyUI拖动购物车案例

    <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content=& ...

  4. easyUI draggable插件使用不当,导致拖动div内部文本框无法输入;设置echarts数据为空时就显示空白,不要动画和文字

    先上一个Demo <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ww ...

  5. EasyUI ---- draggable可拖动的用法

    <link href="~/Scripts/easyui1.5/themes/default/easyui.css" rel="stylesheet" / ...

  6. EasyUI - Draggable 拖动控件

    效果: html代码: <div id="box" style="width: 400px; height: 200px; background-color: #f ...

  7. EasyUI Draggable 可拖动

    通过 $.fn.draggable.defaults 重写默认的 defaults. 用法 通过标记创建可拖动(draggable)元素. <div id="dd" clas ...

  8. ASP.NET MVC5+EF6+EasyUI 后台管理系统(55)-工作流设计-表单布局

    系列目录 前言:这一节比较有趣.基本纯UI,但是不是很复杂 有了实现表单的打印和更加符合流程表单方式,我们必须自定义布局来适合业务场景打印!我们想要什么效果?看下图 (我们没有布局之前的表单和设置布局 ...

  9. JQuery easyui (1) Draggable(拖动)组件

    很不习惯这种强迫式的学习,但谁叫我不是老师了,所以还是决定坚持练习,顺带为博客加点东西.虽然我还是很反感短时间内惯性的去熟悉一个工具. easyui做为一个封装了JQusey的UI插件,其实还是蛮好用 ...

随机推荐

  1. Flask中'endpoint'(端点)的理解

    翻译整理自Stack Overflow:http://stackoverflow.com/questions/19261833/what-is-an-endpoint-in-flask 原文中用到了m ...

  2. 9/24matplotlib简介

    Matplotlib是一个在python下实现的类matlib的纯python的三方库,旨在用python实现matlib的功能,是python下最出色的绘图库,功能很完善,其风格根matlib很相似 ...

  3. idea 上搭建 Mybatis 逆向工程

    网盘地址:https://pan.baidu.com/s/1VAILpdgQbFk9t89eEv_nWQ 提取码:xdyc

  4. python练习题-简单方法判断三个数能否组成三角形

    python简单方法判断三个数能否组成三角形 #encoding=utf-8 import math while True: str=raw_input("please input thre ...

  5. Linux基础命令---rmdir

    rmdir 删除一个空目录,可以同时删除途经的父目录,但是要确保父目录中没有其他内容. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. ...

  6. Window下PHP三种运行方式图文详解,window下的php是不是单进程的?

    Window下PHP三种运行方式图文详解,window下的php是不是单进程的? PHP运行目前为止主要有三种方式: a.以模块加载的方式运行,初学者可能不容易理解,其实就是将PHP集成到Apache ...

  7. Python入门之Pycharm开发中最常用快捷键

    要查阅Pycharm的快捷键,当然要看官方文档,https://www.jetbrains.com/help/pycharm/mastering-keyboard-shortcuts.html 编辑类 ...

  8. Python3 pip出现Fatal error in launcher: Unable to create process using '"'

    Python3 pip出现Fatal error in launcher: Unable to create process using '"' 问题分析: 先python2又安装了pyth ...

  9. 根据wsdl,基于wsimport生成代码的客户端

    根据wsdl,基于wsimport生成代码的客户端 wsimport是jdk自带的命令,可以根据wsdl文档生成客户端中间代码,基于生成的代码编写客户端,可以省很多麻烦. 局限性:wsimport   ...

  10. 20145311王亦徐《网络对抗技术》MAL_逆向与Bof基础

    20145311王亦徐<网络对抗技术>MAL_逆向与Bof基础 实践目标 运行一个可执行文件,通过逆向或者Bof技术执行原本不应该执行的代码片段采用的两种方法: 1.利用foo函数的Bof ...