0

ファイルのリストがあり、各ファイルのクリックイベントで、ファイル名を取得し、ファイル名を解析してextensionタイプを取得します。

extension = $('#'+id_href).text().split('.').pop();

ここで、ajax現在のファイル拡張子に関するデータを取得するために呼び出しを行う必要があります。

拡張配列に拡張データが既に保存されている場合、ajax api 呼び出しを防止したいと考えています。

私の拡張配列は次のようになりますa[extension_1] = html_data_1, a[extension_2] = html_data_2

位置が既に存在するかどうかを確認したいのですextension_1が、存在しない場合は、データを取得するために ajax 呼び出しを行う必要があります。

行を何に置き換える必要がありif(!array_extension[extension])ますか?

var array_extension = new Array();

ImgAjaxLoader = "$url_img"+'ajax-loader.gif';
ImgI = "$url_img"+'info_icon.png';
$("html").live("click", function() {
    $(".info_box").hide();
});
$(".info").live("click",function(e){
    e.stopPropagation();
    var elem = $(this);
    $(".info_box").hide();
    position = $(this).offset();
    var id = 'container_tooltip';
    var id_img = $(this).attr('id');
    var id_href = $(this).attr("id").replace("image_","href_");
    $('#'+id_img).attr('src',ImgAjaxLoader);
    $('#'+id).toggle(100, function() {
        if($(this).css('display') == 'block') {
            extension = $('#'+id_href).text().split('.').pop();
            //if(!array_extension[extension])
            $.ajax({
                url: "$url",
                data: { document_id:elem.attr('document_id') },
                success: function (response) {
                    //console.log(response);
                    response = JSON.parse(response);
                    array_extension[response.extension] = response.html;
                    $('#'+id).html(response.html);
                    $('#'+id).css({'top':(position.top-110)+'px','left':(position.left+30)+'px'});
                    $('#'+id_img).css({'width':'20px','height':'20px',"padding":"0px"});        
                    $('#'+id_img).attr('src',ImgI);
                }
            });
            }
        });
});
4

0 に答える 0