1

画像をアップロードするモーダルがあります。
その画像は次のように返されます。

<input type="hidden" value="20130108A70WY2.jpg" name="image_message_file" id="image_message_file">
<img src="http://files.gestionradioqc.com/immedia/message/picture/2013/01/08/20130108A70WY2_300.jpg">

次に、次のようなJavaScriptを使用してデータをメインページに転送します。
<-EDITED->

function addAttachmentsToMessage(){
    var picture = $("#image_message_preview").find('img').parent().html();
    alert(picture);
    if(picture != ''){
        $("#message_attachments").append("<div class='attachment cf'>"+
                                        "<ul class='att-picture cf'>"+
                                            "<li>"+picture+"</li>"+
                                        "</ul>"+
                                    "</div>");
        clearAttachments();
    }
}

function clearAttachments(){
    $("#image_message_file").attr('value', '');
    $("#image-message").attr('value', '');
    $("#image_message_loading").hide();
    $("#image_message_upload").show();
    $("#image_message_preview").hide();
}

<-/編集済み->

アラートは実際には正しいです。
しかし、実際にmessage_attachmentsに追加されるのは、次のとおりです(非表示フィールドに値はありません)。

<input type="hidden" value="" name="image_message_file" id="image_message_file">
<img src="http://files.gestionradioqc.com/immedia/message/picture/2013/01/08/20130108A70WY2_300.jpg">

しかし、追加された最初の画像だけがその問題を抱えています。
他は大丈夫です。
Firefox 17、Chrome 23、IE9でも同じ問題が発生します。

私の問題は何ですか?

4

2 に答える 2

0

$("#image_message_preview")投稿されたSO画像アラートが「未定義」としてマークアップにアクセスしていないので、コードの貼り付け/マークアップの問題が必要ですか?「image_message_file」

私はラッピング/適切な命名などの自由を取りました、そしてそれはここで値を警告するように働きます:

http://jsfiddle.net/eBTYC/

于 2013-01-08T21:16:32.413 に答える