2013-07-30 2 views
0

저는 여기에 붙어 있습니다 :프로모션/버블 랩 테이블 스크린 데이터

내 앱에 데이터를 채워야합니다.

class Parties < ProMotion::TableScreen 
    attr_accessor :_cells 
    @news = [] 
    include MyUiModules 
    title 'Yazarlar' 
    refreshable callback: :on_refresh, 
    pull_message: "Pull to refresh", 
    refreshing: "Refreshing data…", 
    updated_format: "Last updated at %s", 
    updated_time_format: "%l:%M %p" 
def on_refresh 
    #MyItems.pull_from_server do |items| 
    #@my_items = items 
    end_refreshing 
    #update_table_data 
    # end 
end 

def table_data 
    _cells = [] 
    [{ 
    title: nil, 
    cells: create_cells(_cells) 
    }]    
end 
def will_appear 
    Barbutton.create_bar(self) 
    set_attributes self.view, { 
     backgroundColor: hex_color("DBDBDB") 
    }   
    end 

    def go_to_next 
    App.delegate.slide_menu.show_menu  
    end 

    def create_cells(_cells) 

    BW::HTTP.get(URL) do |response| 
    json = BW::JSON.parse response.body.to_str 
    for line in json 
     _cells << { title: line["val_for_title"]} 
    end 
    end 
    _cells 
    end 
end 
: 나는 난생 처음 진흥을 사용하고

.... 홍보없이

내가 init 메소드에서 데이터를 가져 오기 위해 사용은

지금 내 코드는 다음과 같습니다

Unfotunately 이것은 빈 배열을 반환하고 해결 방법을 찾을 수 없습니다. 당신의 도움이

+0

https://github.com/clearsightstudio/ProMotion/issues/248#issuecomment-21821293 – silasjmatson

답변

3

당신은 할 수 없습니다 BW 때문에 :: HTTP.get에 대한 들으 비동기입니다! 이 같은

대신

시도 뭔가 :

def on_init 
    @data = [] 
end 

def table_data 
    [ 
    { 
     title: nil, 
     cells: @data 
    } 
    ]    
end 

def on_refresh 
    BW::HTTP.get(URL) do |response| 
    @data = [] 
    json = BW::JSON.parse(response.body.to_str) 
    json.each do |hash| 
     @data << { title: hash["val_for_title"]} 
    end 
    update_table_data 
    end_refreshing 
    end 
end 

는 희망이 도움이 :-)