2012-01-14 62 views
3

我正在做我的應用程序中的一部分,需要一個HTML塊被加載到一個valueCell函數中。Liftweb WiringUI和JQueryUI衝突

我的代碼正在工作,但JQuery沒有完成它的工作,不顯示選項卡。我可以閱讀「Hello world」和標籤名稱,但我沒有標籤佈局。另外,我可以補充一點,如果我刪除了使用Wiring UI(只需在html頁面中使用displayFormOK而不是displayForm),它就可以很好地工作。

這是我的代碼:

片段:

object Menu { 

    val searchType = ValueCell[Option[SearchType]](Some(Type1)) 
    //I removed some stuff to update the cell 

    def displayForm = { 
    WiringUI.apply(searchType)(displayFormAjax) 
    } 

    def displayFormOK ={ 
    displayFormAjax(searchType.get)(NodeSeq.Empty) 
    } 

    def displayFormAjax(sType: Option[SearchType])(n:NodeSeq):NodeSeq = 
    {sType match{ 
     case None => <h3> Error on type </h3> 
     case Some(x) => {x.displayForm} 
    }} 
} 

在這裏被選擇表示對象我的性狀

trait SearchType { 
    val name:String 
    def displayForm:NodeSeq = { 
    <div id="tabs"> 
     <ul> 
     <a href={"#"+name}> {name} </a></li>)} 
     </ul> ++ 
     <div id={name}>Hello World </div> 
    </div> 
)} 
} 

在該性狀的代碼是更復雜的,其實我想要生成任意數量的選項卡。

最後,這裏是我的html代碼

<script> 
    $(function() { 
     $("#tabs").tabs(); 
    }); 
</script> 

<form class="lift:form.ajax">   
    <div class="lift:Menu.displayForm"></div> 
</form> 
+0

您是否在Web瀏覽器中檢查了JavaScript控制檯是否有錯誤? – 2012-01-14 21:09:39

+0

我剛剛檢查過,沒有發生javascript錯誤 – 2012-01-14 22:05:27

+0

我認爲它來源於WiringUI腳本中的「嵌套」選項卡腳本,但我找不到如何很好地使用這些腳本。 – 2012-01-15 08:48:35

回答

1

我找到了解決我的問題。實際上,因爲我在「加載」腳本後添加了一些html塊,所以它不適用於我的塊。所以,每次使用WiringUI時我都必須調用腳本。這是我的解決方案:

def displayForm = { 
    def cmdG(id: String, first: Boolean, setCmd: JsCmd) = new JsCmd{ 
    def toJsCmd = setCmd.toJsCmd + "; $(\"#tabs\").tabs();" 
    } 

    WiringUI.apply(searchType,cmdG _)(displayFormAjax) 
} 

很明顯,我從我的HTML文件中刪除腳本。

注意:我也意識到這不是我的代碼中的最佳解決方案,現在我將使用此JsCmd功能來禁用我不想使用的選項卡。