Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

App.Properties.setList not saving

$
0
0

Seams I have change my json my property stop working... it strop saving my list anymore...

this is my url to my json: http://www.villaassumpcao.com.br/app/admin/pages/categorias.json

I get the Eventos field from that json and assign it to a new window that hold Eventos[0], Eventos[1] ...

When I click on a button it check if property already exists... if not... it create an array and push the right Eventos to it...

var favoritoOn = false
 
if( Ti.App.Properties.hasProperty( 'arrayFavoritos' ) == 1 ){
    var arrayCheck = Ti.App.Properties.getList( 'arrayFavoritos' )
 
    for( var i = 0; i < arrayCheck.length; i++ ){
        if( arrayCheck[i].nomeFesta == nomeFesta ){
            favoritoBtn.setBackgroundImage( 'imagens/likeBtn2.png' )
            favoritoOn = true
            break
        }
    }
}
 
alert( Ti.App.Properties.hasProperty( 'arrayFavoritos' ) )
 
favoritoBtn.addEventListener( 'click', function(){
    if( favoritoOn == false ){
        if( Ti.App.Properties.hasProperty( 'arrayFavoritos' ) == 0 ){
 
            alert( evento )
            var array = []
 
            array.push( evento )
 
            favoritoOn = true
            Ti.App.Properties.setList( 'arrayFavoritos', array )
 
            alert( Ti.App.Properties.hasProperty( 'arrayFavoritos' ) )
 
            favoritoBtn.setBackgroundImage( 'imagens/likeBtn2.png' )
        }else{
 
            var array = Ti.App.Properties.getList( 'arrayFavoritos' )
 
            var existeNoArray = false
 
            for( var i = 0; i < array.length; i++ ){
                if( array[i].nomeFesta == nomeFesta ){
                    existeNoArray = true
                    favoritoBtn.setBackgroundImage( 'imagens/likeBtn2.png' )
                    break
                }
            }
 
            if( existeNoArray == false ){
                favoritoOn = true
                array.push( evento )
                Ti.App.Properties.setList( 'arrayFavoritos', array )
                favoritoBtn.setBackgroundImage( 'imagens/likeBtn2.png' )
            }
        }
    }else if( favoritoOn == true ){
        favoritoOn = false
 
        var arr = Ti.App.Properties.getList( 'arrayFavoritos' )
        var newArr = []
 
        for( var i = 0; i < arr.length; i ++ ){
            if( arr[i].nomeFesta != nomeFesta ){
                newArr.push( arr[i] )
            }
        }
 
        Ti.App.Properties.setList( 'arrayFavoritos', newArr )
        favoritoBtn.setBackgroundImage( 'imagens/likeBtn.png' )
    }   
 
})
I only get Ti.App.Properties.hasProperty( 'arrayFavoritos' ) == 0 because it not saving... someone can help me please?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>