开发者

How can I add textarea dynamically to jquery dialog?

I need to add the textarea to the dialog. Please suggest me if any ideas. Here is my code...

var story = changeStory();  
   $.ajax({  
        async: false,  
        type:"GET",  
    data:{"story":story},  
    url: "./teststory.action",  
    dataType: 'json',  
    success: function(json){  
    var i = 0;
    var jsonList = "";  
      $.each(json, function(index,job) {    
        if(i > 0){  
            jsonList = jsonList + ",";  
        }    
        jsonList = jsonList + "[";  
        jsonList = jsonList + "{";  
        ......  
        jsonList = jsonList + "}";   
        jsonList = jsonList + "]";  
        **var newDiv = $(document.createElement('div'));  
        $(newDiv).text();  
        $(newDiv).dialog({modal: true, width:850, height:500, title:"JSON for Demo开发者_开发知识库 Story"}).dialog("open");**  
        *var obj=document.createElement('textarea');  
        obj.setAttribute("style","padding-left:100");  
        obj.value=jsonList;  
        document.body.appendChild(obj);*   
        storyLst = jsonList;  
        });  
    }  
});  


You can append any element in the div you use as the dialog content.

var newDiv =  $("<div />"); 
var textArea = $('<textarea style="padding-left:100px" />'); 
textArea.text(jsonList);
newDiv.append(textArea);
newDiv.dialog({modal: true, width:850, height:500, title:"JSON for Demo Story"});

See jQuery documentation for insertion for more functions.


some javascript

$( "#dialog-form" ).dialog({
    autoOpen: false,
    height: 600,
    width: 600,
    modal: true,
    ...............................
});

and then some html(you basically have a div with a form inside)

<div id="dialog-form" title="<?php echo $this->translate('rifiuta ordine titolo') ?>">
    <form action="/<?=$controller?>/rifiuta/" method="post" name="rifiuta_form">
    <fieldset>
        <label for="motivo"><?php echo $this->translate('note_interne')?></label>
        <br />
        <br />
        <textarea name="motivo" id="motivo" class="text ui-widget-content ui-corner-all" rows="25" cols="50" style="height:100%; width: 100%"></textarea>
        <input type="hidden" name="id" id="ordine_id" value="" />
        <input type="submit" id ="submit_button" style="display:none" />
    </fieldset>
    </form>
</div>

this works as i use it in on a website...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜