Tuesday 2 December 2014

jquery selectable

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication10.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">

  <style>
  #feedback { font-size: 1.4em; }
  #selectable .ui-selecting { background:#bdbcbc; }    
  #selectable .ui-selected { background: #bdbcbc; color: white; }
  #selectable { list-style-type: none; margin: 0; padding: 0; width: 20%; }
  #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
  </style>
  <script>
      $(function () {
          $("#selectable").selectable({
              stop: function () {
                  var result = $("#select-result").empty();
                  $(".ui-selected", this).each(function () {
                      var index = $("#selectable li").index(this);
                      result.append(" #" + (index + 1));
                  });
              }
          });
      });
  </script>
</head>
   
<body>

<p id="feedback">
<span>You've selected:</span> <span id="select-result">none</span>.
</p>

<ol id="selectable">
  <li class="ui-widget-content">General Data</li>
  <li class="ui-widget-content">Communication Data</li>
  <li class="ui-widget-content">Other Data</li>
</ol>
</body>
</html>

No comments:

Post a Comment