0

你能告诉我如何在 jQuery 的参数中发送路径数组(所有数组值)吗?

我正在使用这个插件:https ://github.com/phonegap/phonegap-plugins/blob/master/iOS/EmailComposerWithAttachments/readme.md

有一个

window.plugins.emailComposer.showEmailComposerWithCallback(
    function(result) {
        console.log(result);
    },
    "Look at this photo",
    "Take a look at <b>this<b/>:",
    ["example@email.com", "johndoe@email.org"],
    [],
    [],
    true,
    ["_complete_path/image.jpg"]
);

路径参数。

$(document).on('click', '.email_h', function() {
    setTimeout(function(){
        var txtfilepath= window.localStorage.getItem("TEXTFILE_PATH"); 
        var PATH =new Array();
        for(var i=0;i<10 ;i++){
            PATH[i]=txtfilepath+'/'+CASENAME+'/'+DOCUMENT_NAME+'.rtf';
        }
        alert(PATH[0]);
        alert(PATH[1]);
        var Email_PATH=txtfilepath+'/'+CASENAME+'/'+DOCUMENT_NAME+'_email.html';
        connectionStatus = navigator.onLine ? 'online' : 'offline';
        if(connectionStatus=="offline"){
            PG_alert(" No Internet connection ! ");
        } else {
            window.plugins.emailComposer.showEmailComposerWithCallback(
                function(result){
                    if(result==0){
                        PG_alert("Email composition cancelled.")
                    } else if(result==1) {
                        PG_alert("Email saved.")
                    } else if(result==2) {
                        PG_alert("Email sent")
                    } else if(result==3) {
                        PG_alert("Send fail.")
                    } else if(result==4) {
                        PG_alert("Email not sent.")
                    }
                    console.log(result+"Result");
                },
                "Case Documents ",
                "I am forwarding the attached for your information... <b><b/>",
                [""],
                [],
                [],
                true,
                [PATH[0],PATH[1]]
            );
            //window.plugins.emailComposer.showEmailComposerWithCallback(null,"Look at this photo","Take a look at <b>this<b/>:",["example@email.com", "johndoe@email.org"],[],[],true,["_complete_path/image.jpg", "_other_complete_path/file.zip"]);
    }
},100);

我需要发送 PATH 数组(具有所有值)。当我像这样放置 PATH[0],PATH[1]] 时,它正在工作,它需要路径。如果我需要发送所有路径(10 路径是 PATH 变量)。怎么可能。

Not like that PATH[0],PATH[1]PATH[2],PATH[3]


});
4

1 回答 1

0

试试这个demo你就明白了。

    <!DOCTYPE HTML>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>Desktops and Tablets</title>

    <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>

    <style media="screen" type="text/css">


    </style>

    <script type="text/javascript">
        $(document).ready(function () {

          var arr = new Array();

            for(i=0;i<=10;i++){
               arr[i]=i;
            }

            var teststring = arr.join(",");

            console.log(teststring);

            /* Conole log asnswer ::  0,1,2,3,4,5,6,7,8,9,10   */

          });

    </script>
    </head>
    <body>
    </body>
    </html> 

你只需要这样做 ::::

var PATH =new Array();

 for(var i=0;i<10 ;i++){
 PATH[i]=txtfilepath+'/'+CASENAME+'/'+DOCUMENT_NAME+'.rtf';
 }

 var allpath = PATH.join(",");

  console.log(allpath);
于 2013-10-28T05:23:16.713 回答