开发者

want to display the parent and child value?

开发者 https://www.devze.com 2023-03-24 01:43 出处:网络
i need to display the parent and child value. but here i have got the value only one side. but i need both sides.

i need to display the parent and child value. but here i have got the value only one side. but i need both sides.

for example:

i have list like below:

title1
  yellow
  pink

title2
  green
  rose

if i drag the yellow and place it into title2. then i have 开发者_高级运维to display the value of parent and child like this

title1_pink(yellow drag and placed it into title2)
title2_green
title2_yellow
title3_rose

here fiddle link: http://jsfiddle.net/thilakar/mwypv/16/


You could do:

var origTitle;
var origColor;
$(".droptrue").sortable({
    connectWith: "ul.mt",
    dropOnEmpty: true,
    start: function(event, ui) {
        origColor = ui.item.text();
        origTitle = ui.item.parent().siblings('.Tbltitle').text();
    },
    stop: function(event, ui) {
        var order = [];

        ui.item.closest('ul').children('li').each(function() {
            order.push($(this).data('position'));
            var c = $(this).text();
            if (c === origColor) {
                var z = origTitle;
            } else {
                var z = $(this).parent().siblings('.Tbltitle').text();
            }
            $("#cl").append(z + "_" + c + "<br />");
        });
    }
});

Fiddle here: http://jsfiddle.net/nicolapeluchetti/mwypv/17/

0

精彩评论

暂无评论...
验证码 换一张
取 消