prependTo()不添加新元素

时间:2015-05-08 13:55:18

标签: jquery

我使用WowBook, a flipbook jQuery plugin,我需要使用thumbnails_generator.js来生成缩略图。

我在我的页面上添加了这个脚本

<script src="Scripts/js/thumbnails_generator.js"></script>

但脚本无法正常工作。

thumbnails_generator.js

;(function($) {

/* A lot of other functions */

function createUI(){
    console.log(1);
    var div = $("<div>").prependTo("body").css({
        background: "white",
        border:"1px solid black",
        position: "absolute",
        padding: "8px",
        zIndex: 100000,
        top: 0,
        left: 0
    });
    console.log(2);

    var button = $("<button style='position: relative; top:0; left: 0'>Generate Thumbnails</button>");
    button.appendTo(div);
    $("<div id='progress' style='display: none;'><span class='loaded'>0</span> / <span class='total'></span> pages loaded</div>").appendTo(div);
    var anchor = $("<a download='thumbnails.png' style='display:block'>Click to download thumbnails</a>");
    button.click(function(){
        var book = $.wowBook( $(".wowbook") );
        $('#progress').css("display", "block").find(".total").text( book.pages.length );
        loadAllPages( book, function(){
            var canvas  = createThumbnailsSprite( book );
            var data    = canvas.toDataURL('image/png');
            anchor[0].href = data; // dt.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
            div.append(anchor).append(canvas);
        })
    });
    return
} // createUI

createUI();


})(jQuery);

console.log(1);有效且console.log(2);也有效,但var div = $("<div>").prependTo("body")无法正常工作,也无法在页面上添加任何新元素。我试图理解错误是什么让我全神贯注?

1 个答案:

答案 0 :(得分:1)

改变这个:

javax.persistence.TransactionRequiredException: Executing an update/delete query
    at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:71)
    at com.esisa.pfe.business.DefaultUserService.createDatabase(DefaultUserService.java:56)
    at com.esisa.pfe.controllers.ClientController.addAbonnement(ClientController.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

到此:

createUI();