2012-10-07 24 views

回答

1

invoke any existing JS library其實很簡單。作爲GWT程序員,一旦你熟練掌握這個技術,你的視野就會擴大,而且事實上我會證明這很簡單。

將jQuery和AddThis插件源添加到DOM。例如:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/> 
<script type="text/javascript" src="https://raw.github.com/bdewong/jQuery-AddThis/master/jquery.addthis.js"/> 

某處在您的應用程序,你需要創建一個錨,並指定它的類名前頁,不管你做programically,用UiBinder的模板或普通的老HTML。

<a class="addthis"></a> 

現在你應用程序中的某個地方需要調用addthis插件。這裏有兩個例子功能,您可以使用:

static native void invokeAddThis(String id) /*-{ 
    $wnd.jQuery(id).addthis(); 
}-*/; 

static native void invokeAddthis(String id, String username) /*-{ 
    $wnd.jQuery(id).addthis(username); 
}-*/; 

某處你撥打電話:

invokeAddThis(".addthis"); 

Congradulations!你現在可以掛鉤到現有的JS API的世界:)

相關問題