2013-12-20 31 views
0

我有這個功能,它需要一個文本字符串,如「你好,我的名字是¬¬¬John¬¬¬」,並且該函數試圖輸出被'在彈出式菜單選項列表中彈出一個按鈕,然而,當按鈕顯示正常時,樣式正確並且在懸停時顯示鏈接,點擊時彈出式ul列表不會顯示它。整個功能在上下文中(顯然大部分功能可能與問題無關)。我真的很感激一些幫助,因爲我尋覓一段時間了答案:JQuery mobile - 動態添加彈出不彈出

function displayText(element, txt) 
{ 
    console.log("lesson text:" + txt); 
    var buildtext = '<span>'; 

    if(txt.indexOf("¬¬¬") != -1)  
    { 
     var splitarr = txt.split("¬¬¬"); 

     for (var i=0;i<splitarr.length;i++) 
     { 

      if(i%2 == 1) 
      { 
       buildtext += '<a href="#fwordPopupMenu' + i + '" data-rel="fwordPopup" data-role="button" data-inline="true" data-transition="slideup" data-icon="false" data-theme="e">' + splitarr[i] + '</a>' + 
           '<div data-role="popup" id="fwordPopupMenu' + i + '" data-theme="d">' + 
           '<ul data-role="listview" data-inset="true" style="min-width:210px;" data-theme="d">' + 
           '<li><a href="#">View details</a></li>' + 
           '</ul>' + 
           '</div>'; 
      } 
       else 
      { 
       buildtext += splitarr[i]; 
      }       
      console.log(splitarr[i]); 
     } 
     buildtext += '</span>'; 
    } 
    else // text contains no special words so display as is 
    { 
     buildtext = txt; 
    } 

    $(element).html(buildtext); 

    if(element == '#tutor-paragraph') 
    { 
     //document.getElementById("tutor-paragraph").style.webkitAnimationName = ""; 
     console.log("reseting animation"); 
     $('#tutor-paragraph').addClass('run-animation'); 
     //document.getElementById("tutor-paragraph").style.webkitAnimationName = "example"; 
    } 
    //refresh element to get styling 
    $(element).trigger('create'); 
    //$('element').selectmenu('refresh', true); 
    } 

回答

0

當你建立鏈接,改變

data-rel="fwordPopup" 

data-rel="popup" 

這裏a DEMO

+0

謝謝!很好發現 - 我認爲這可能是一個非常技術性的問題,但事實證明,這是我的一個愚蠢的錯誤.. – Dave