1

こんにちは、画像が追加され、既存の画像が削除または編集されるバックボーン アプリケーションに取り組んでいます。現在、ギャラリー、フォームなどのさまざまなセクションにルーターを使用していますが、ギャラリーで何かを編集すると、フォームに戻って戻ってきて、以前に行った変更が得られません。代わりに、古いデータが表示されます。更新する必要があります。つまり、CTRL + F5 を使用して変更を確認する必要がありますが、これは良くありません。

コレクションとモデルをリセットする .clear と .reset を試しましたが、コレクション内のデータには影響しません。私が間違っているところを誰か助けてください。

以下は Collection と model のコードです:

var GalleryImage = Backbone.Model.extend({});

 var GalleryImages = Backbone.Collection.extend({
model : GalleryImage,
url: '######',
initialize : function(){


    this.reset();
    if(this.reset())
    {
        console.log("model reset", GalleryImage.cid)
    }else{
        console.log("model not set")
    }

    this.on("reset", this.loadImagesView,this);
    this.on("error", this.errorMessage,this);
        //console.log(GalleryImages.get(0))

},
loadImagesView : function(){
    //console.log(this);
    //console.log(this.CollView.$el);
    if(!this.CollView){
        this.CollView = new GalleryImagesView({collection:this})
    }
        this.CollView.render(); 

},
errorMessage : function(){
    jQuery('#imageBlocksDiv').html('<span id="noMsg"><h4>No images to display.</h4></span>');
}

});

ルーターの場合は次のとおりです。

initGallery : function(){

            jQuery('#invset').hide();
            jQuery('#imagelist').children().eq(0).append(jQuery('.floor_img').find('#box').css({'z-index':'1','position':'relative','margin-top':'0px','margin-left':'0px'}));
            pinterest(undefined);
    jQuery("#box").show();
            jQuery('#invset').hide();
            jQuery('#inventorycontent').hide();
    jQuery("#boxnews").hide();
    jQuery("#boxzip").hide();
    jQuery(".select").attr('style','display:block');
    jQuery(".select").attr('id','ugallerygal');
    jQuery(".pagetitle").html('Gallery');
    var that = this,projectId = jQuery('#ugallerygal').val();
    jQuery('#imageBlocksDiv').html('');
    var imgObj = new GalleryImages();

    //this.reset(imgObj);

    imgObj.fetch({data: jQuery.param({projectId: projectId, add:true, reset:true}), success:function(){
                      console.log(imgObj)
                      imgObj.trigger("reset");
          },
          error : function(){
          imgObj.collection.trigger("error");
          }
    });

},

これだけでなく、ユーザーが画像をクリックすると画像が開き、画像の任意の場所をクリックすると、ポイントを配置してそのポイントに詳細を追加し、解析に保存するセクションがありますが、変更の値は保存されますが、画像に戻ると、パースに保存されている新しい位置と更新されたポイントの代わりに、古い位置と番号の画像が表示されます。問題は両方の州で同じだと思うので、1つの解決策はすべての州で機能します。

どんな助けでも大歓迎です。事前に感謝

ありがとう、サントッシュ・ウパダヤイ

4

1 に答える 1

0

問題は、リセットとリセット リスナーの追加の順序にある​​可能性があります。変更してみる

this.reset();
if(this.reset())
{
    console.log("model reset", GalleryImage.cid)
}else{
    console.log("model not set")
}

this.on("reset", this.loadImagesView,this);
this.on("error", this.errorMessage,this);

this.on("reset", this.loadImagesView,this);
this.on("error", this.errorMessage,this);
this.reset();
if(this.reset())
{
    console.log("model reset", GalleryImage.cid)
}else{
    console.log("model not set")
}
于 2013-11-04T15:21:05.493 に答える