узел клона на перетаскивании

class ArticleWithoutAuthorSerializer(ArticleSerializer):
    # Prevent author field serialization and endless nesting
    author = None

class AuthorSerializer(ModelSerializer):
    articles = SerializerMethodField()

    def get_articles(self, author):
        # Five recently posted articles
        articles = author.article_set.order_by('-published')[:5]
        return ArticleWithoutAuthorSerializer(articles, many=True).data

    class Meta:
        model = Author
21
задан Justin Johnson 2 February 2010 в 09:31
поделиться

2 ответа

Mark,

Попытка этот пример:

        $(document).ready(function(){
        $(".objectDrag").draggable({helper:'clone'});  

        $("#garbageCollector").droppable({
            accept: ".objectDrag",
            drop: function(event,ui){
                    console.log("Item was Dropped");
                    $(this).append($(ui.draggable).clone());
                }
        });

    });

И HTML похож на это

        <div class="objectDrag" 
        style="width:10%; color:white;border:black 1px solid; background-color:#00A">Drag me</div>

    <div id="garbageCollector" style="width:100%; height:400px; background-color:#333; color:white;"> Drop items on me</div>
35
ответ дан 29 November 2019 в 20:17
поделиться

Чтобы перетащить клон/копию, установите аргумент withDataAndEvents в true:

$(this).append($(ui.draggable).clone(*true*));
2
ответ дан 29 November 2019 в 20:17
поделиться
Другие вопросы по тегам:

Похожие вопросы: