JQuery Easyui Tree's Oncheck event implementation code _jquery

Source: Internet
Author: User


Using Firebug to view its generated HTML, find that its checkobx is fake, just a span, back and forth of the variable style only, Khan


Copy Code code as follows:

$ (". Tree-checkbox", tree). Unbind (". Tree"). Bind ("Click.tree", function () {
if ($ (this). Hasclass ("tree-checkbox0")) {
$ (this). Removeclass ("tree-checkbox0"). AddClass ("Tree-checkbox1");
} else {
if ($ (this). Hasclass ("Tree-checkbox1")) {
$ (this). Removeclass ("Tree-checkbox1"). AddClass ("tree-checkbox0");
} else {
if ($ (this). Hasclass ("Tree-checkbox2")) {
$ (this). Removeclass ("Tree-checkbox2"). AddClass ("Tree-checkbox1");
}
}
}
_2eb ($ (this). parent ());
_2EC ($ (this). parent ());
return false;
});

And then look at its onclick event script
Code
Copy Code code as follows:

$ (". Tree-node", tree)
....
Bind ("Click.tree", function () {
$ (". tree-node-selected", tree). Removeclass ("tree-node-selected");
$ (this). addclass ("tree-node-selected");
if (Opts.onclick) {
var _2ea = this;
var data = $.data (this, "Tree-node");
Opts.onClick.call (this, {id:data.id, text:data.text, attributes:data.attributes, Target: _2ea});
}
})

Modify its check script accordingly
Copy Code code as follows:

$ (". Tree-checkbox", tree). Unbind (". Tree"). Bind ("Click.tree", function () {
if ($ (this). Hasclass ("tree-checkbox0")) {
$ (this). Removeclass ("tree-checkbox0"). AddClass ("Tree-checkbox1");
} else {
if ($ (this). Hasclass ("Tree-checkbox1")) {
$ (this). Removeclass ("Tree-checkbox1"). AddClass ("tree-checkbox0");
} else {
if ($ (this). Hasclass ("Tree-checkbox2")) {
$ (this). Removeclass ("Tree-checkbox2"). AddClass ("Tree-checkbox1");
}
}
}
_2eb ($ (this). parent ());
_2EC ($ (this). parent ());
return false;
}. Bind ("Click.tree", function () {//gzl added
if ($ (this). Hasclass ("Tree-checkbox1") && Opts.oncheck) {
var _2e9 = this;
var data = $.data (this, "Tree-node");
Opts.onCheck.call (this, {id:data.id, text:data.text, attributes:data.attributes, Target: _2e9});
}
});

But how can not get the data value, and finally have to $ (this). Parent (). Click (), click event Plus check becomes checked, two events in one way, alas.
I would like to have a new version, or a Daniel to change, my ability is too limited.

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.