2012-01-27 2 views
0

위젯을 초기화 할 때 footerText 옵션을 설정하려는 다음 위젯이 있습니다. 어떻게 수행 할 수 있습니까?위젯의 기본 옵션 재정의

$.widget("ui.pdf", { 
    options: { 
     // Service address 
     address: "http://localhost:18362/PDFService.svc/GetPDFWithHeaderAndFooter", 
     //address: "http://test.test.com/PDFService.svc/GetPDFWithHeaderAndFooter", 
     orientation: "Landscape", 
     headerUrl: "http://www.test.com/clients/test/test.html", 
     footerText: "Test", 
     url: "http://www.test.com/portfolio-manager-1/test-test-portfolio1?pdf" //"http://www.test.com/agents-app/test-portfolio-12-01-12-0853" //"http://www.test.com/portfolio-manager-1/test-test-portfolio1" //window.location.href //"http://www.soccernet.com" 
    }, 
    _create: function() { 
     var el = this.element; 
     var o = this.options; 
     $.getScript("http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js", 
      function() { 
       $.template("link", '<a href="${pdfUrl}">download pdf</a>'); 
       $.ajax({ 
        url: o.address, 
        data: { orientation: o.orientation, headerUrl: o.headerUrl, footerText: o.footerText, url: o.url }, 
        dataType: "jsonp", 
        success: function (result) { 
         this.valueTable = $.tmpl("link", result).appendTo(el); 
         $("#loading").hide(); 
        } 
       }); 
      }); 
    }, 
    destroy: function() { 
     this.valueTable.remove(); 
     $.widget.prototype.destroy.apply(this, arguments); // default 
    } 
}); 
})(jQuery); 

답변

1
$(someSelector).pdf({footerText: "someText"}); 
1

그냥 플러그인의 방법에 옵션 개체를 전달할 :

$('#myelement').pdf({ 
    footerText: 'New footer text' 
}); 
관련 문제