Page 1 of 1

Force Card to reload every time it will be opened

Posted: Mon Jan 13, 2020 12:21 pm
by Bosstone
Hi,

I am working with Navigation Bar in my APP. How can I reload the card "Home" every time this card will be opened from stack?

I tried with on openstack and on opencard, but it will not reload

Reason for this: I want to show random exhibitors to the users...

Thank you very much,

Stefan

Re: Force Card to reload every time it will be opened

Posted: Mon Jan 13, 2020 12:32 pm
by Klaus
Hi Stefan,

when you navigate to a card its "pre-/opencard" messages are triggered!
What did you script so far and where did you put the script(s)?


Best

Klaus

Re: Force Card to reload every time it will be opened

Posted: Tue Jan 14, 2020 8:44 pm
by Bosstone
Hi Klaus,

sorry, I am afraid, but I don't get you. I have put the script

Code: Select all

on opencard
   send "loadPreferences" to this stack in 10
end opencard

command loadPreferences
   put readPreferencesToXMLTree() into tTree
   if tTree is empty then
      exit loadPreferences
   end if 
   
end loadPreferences

private function readPreferencesToXMLTree
   
   put random(4) + 1 into rNumber
   
   put url("URLTO/getexhibdata.php?messe=" & rNumber) into tXML
   put revXMLCreateTree(tXML, false, true, false) into tXMLTreeID
   put revXMLRootNode(tXMLTreeID) into tRoot -- "messen"
   put revXMLFirstChild(tXMLTreeID,tRoot) into tResponse -- "messe"
   repeat while "xmlerr" is not in tResponse
      put revXMLNodeContents(tXMLTreeID, tResponse & "/id") into tID
      put revXMLNodeContents(tXMLTreeID, tResponse & "/messe_1") into aRecords[tID]["messe_1"]
      put revXMLNodeContents(tXMLTreeID, tResponse & "/vimeo") into aRecords[tID]["vimeo"]
      put revXMLNextSibling(tXMLTreeID,tResponse) into tResponse
      if tResponse is empty then
         exit repeat
      end if
   end repeat
   put aRecords[tID]["vimeo"] into tVideoURL
   set the url of widget "Browser" to tVideoURL
   put aRecords[tID]["messe_1"] into field "Field"
   
end readPreferencesToXMLTree
to my widget "Browser". I tried first on the stack itself, but got an error message as "Field" could not be found on the other cards...

All the best,

Stefan

Re: Force Card to reload every time it will be opened

Posted: Tue Jan 14, 2020 9:01 pm
by Klaus
Does that help:

Code: Select all

...
put aRecords[tID]["messe_1"] into field "Field" OF CARD "the one with the field" ## OF STACK "If in another stack"
## :-)
...