The beginning of the jquery plug-in production in the Sagecrm query screen hidden part of the line function _jquery

Source: Internet
Author: User
Solution Idea:
1. Add a "-" + "number in the header for the user to click.
2, the user shrinks and expands the screen the behavior to save in the cookie inside. The page reloads or the user logs on to the system, still remembering the user's behavior.
  
Advantages: 1, use the form of jquery plug-ins to do, easy to expand. Easy to achieve.
2, stored in the cookie behavior, easy to achieve, reduce workload, users can also receive. If saved in the database, increase the load on the page.
Disadvantage: You cannot use individual behavior for each page: both the contraction and extension of the user are global in the system. And when you log on to another computer, or when you clear the cache, you cannot remember the user's actions.
  
First use the JS function of the way to achieve. Then change to the jquery plugin: code
Copy Code code as follows:

/*
* Tabletoggle 0.1
* Copyright (c) Novus_lee Http://www.cnblogs.com/novus
* date:2011-12-23
* Hide part of the line's function in the SAGECRM query screen
*/
(function ($) {
$.fn. Tabletoggle = function (options) {
var defaults = {
PLUSSRC: "/upload/201112/20111226224658296.gif",//--[+] Picture
MINUSSRC: "/upload/201112/20111226224658809.gif",
Line:2
}
var options = $.extend (defaults, options);
var flip = 0, i = 0;
This.each (function () {
var $thisTable = $ (this);
var claname = "Btntoggle" + i;
--Add Picture button above the table
var $Title = $thisTable. Parent () parent (). Parent (). Find (TD. Panerepeat ");
$Title. Prepend ("<a href= ' javascript:void (0); ' class= '" + claname + "' style= ' cursor:pointer;padding-right:10px;" ></a> ');
var Trlen = $thisTable. Find ("tr"). Length;
Options.line = (Options.line > Trlen? trlen:options.line);
$Title. Find ("A." + Claname). Click (function () {
$thisTable. Find ("tr:gt (" + Options.line +) "). Toggle (flip++);
if (flip% 2 = 0)
{
$Title. Find ("img[src*= ' Smallplus ']"). attr ("src", options.minussrc);
$.cookie (Claname, "plus");
}
Else
{
$Title. Find ("img[src*= ' Smallminus ']"). attr ("src", options.plussrc);
$.cookie (Claname, "Smallminus");
}
});
if ($.cookie (claname) = "Smallminus" | | | $.cookie (claname) = = "" | | $.cookie (claname) = = null)
{
$ ("A." + Claname). Click ();
}
i++;
});
};
}) (JQuery);

The plugin also invokes a jquery cookie plugin.
Method to invoke:
Copy Code code as follows:

<script type= "Text/javascript" src= ". /scripts/jquery.js "></script>
<script type= "Text/javascript" src= ". /scripts/cookie.js "></script>
<script type= "Text/javascript" src= ". /scripts/toggleblock.js "></script>
<script type= "Text/javascript" >
<!--
$ (function () {
$ ("table.") Content:eq (0) "). Tabletoggle (2);
})
-->
</script>

Effect as shown:

Contraction:

Expand

PS:SAGECRM is what only supports IE7, IE8. So the plugin here doesn't test browser compatibility.

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.