andyhill Posted July 23, 2023 Share Posted July 23, 2023 try JSInterface.JSCallGlobal('localStorage.removeItem', ['_K1_']); JSInterface.JSCallGlobal('localStorage.removeItem', ['_K2_']); except end; try Button.JSInterface.JSCallGlobal('localStorage.removeItem', ['_K1_']); Button.JSInterface.JSCallGlobal('localStorage.removeItem', ['_K2_']); except end; Can someone please advise why RemoveItem fails to remove ? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 23, 2023 Share Posted July 23, 2023 Hello Andy, On what device, what browser? Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 23, 2023 Author Share Posted July 23, 2023 Desktop Windows Chrome Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 23, 2023 Share Posted July 23, 2023 9 minutes ago, andyhill said: Desktop Windows Chrome Why did you mark in the title of the post as mobile? Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 23, 2023 Author Share Posted July 23, 2023 Because it is mobile (touch) on desktop /m Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 23, 2023 Share Posted July 23, 2023 22 minutes ago, andyhill said: Because it is mobile (touch) on desktop /m Okay. 2 hours ago, andyhill said: Can someone please advise why RemoveItem fails to remove ? What exactly? Not removed? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted July 23, 2023 Share Posted July 23, 2023 3 hours ago, andyhill said: try JSInterface.JSCallGlobal('localStorage.removeItem', ['_K1_']); JSInterface.JSCallGlobal('localStorage.removeItem', ['_K2_']); except end; try Button.JSInterface.JSCallGlobal('localStorage.removeItem', ['_K1_']); Button.JSInterface.JSCallGlobal('localStorage.removeItem', ['_K2_']); except end; Can someone please advise why RemoveItem fails to remove ? Thanks in advance Hello, This can help you: http://forums.unigui.com/index.php?/topic/12306-how-can-i-access-local-storage/&do=findComment&comment=65734 Did you, first set your key _K1_ ? Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 23, 2023 Author Share Posted July 23, 2023 Key set and easily seen in chrome development tools, already viewed all posts on localstorage. Mobile (touch) fails to remove ??? Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 23, 2023 Author Share Posted July 23, 2023 I am running this code in a Login Form. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 23, 2023 Share Posted July 23, 2023 13 hours ago, andyhill said: try JSInterface.JSCallGlobal('localStorage.removeItem', ['_K1_']); JSInterface.JSCallGlobal('localStorage.removeItem', ['_K2_']); except end; try Button.JSInterface.JSCallGlobal('localStorage.removeItem', ['_K1_']); Button.JSInterface.JSCallGlobal('localStorage.removeItem', ['_K2_']); except end; In what place, event, do you use this piece of code? Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 23, 2023 Author Share Posted July 23, 2023 UnimLoginFormAjaxEvent localStorage.setItem WORKS localStorage.removeItem DOES NOT WORK Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 24, 2023 Author Share Posted July 24, 2023 Exhaustive testing shows TfLogin = class(TUnimLoginForm) ALL localStorage.setItem and localStorage.removeItem FAILS TfMain = class(TUnimForm) ALL localStorage.setItem and localStorage.removeItem APPEARS TO WORK Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 25, 2023 Share Posted July 25, 2023 Hello, Your case is not clear: On 7/24/2023 at 12:33 AM, andyhill said: UnimLoginFormAjaxEvent This event is called many times, and it is not good practice to use it without specifying the EventName parameter. Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 25, 2023 Author Share Posted July 25, 2023 Sherzod, the event name was left out in my post for clarity. It is normal programming that only has issues (not working) with Touch Login Form. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted July 25, 2023 Share Posted July 25, 2023 11 hours ago, andyhill said: it is normal programming that only has issues (not working) with Touch Login Form. I tested with Touch Login Form and works fine ! procedure TfrmLogin.UnimButton1Click(Sender: TObject); var st:string; begin st:=UnimEdit1.Text; UnimButton1.JSInterface.JSCallGlobal('localStorage.setItem', ['K1', st] ); // Key , Value (always string) end; procedure TfrmLogin.UnimButton2Click(Sender: TObject); begin with UnimEdit2.JSInterface do JSCall('setValue', [jsstatement('localStorage.getItem("K1")')]); // important : Key must be Quoted " " end; procedure TfrmLogin.UnimButton3Click(Sender: TObject); begin UnimButton3.JSInterface.JSCallGlobal('localStorage.removeItem', ['K1']); end; - Unigui Build 1568 - Chrome Version 115.0.5790.102 (Build officiel) (64 bits) See attached LoginMobile.zip LoginMobile.zip Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 25, 2023 Author Share Posted July 25, 2023 Thank you but I am not actually using a Button or an Editor, I am doing it via a FORM AjaxEvent inside a mLoginForm. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted July 25, 2023 Share Posted July 25, 2023 1 hour ago, andyhill said: Thank you but I am not actually using a Button or an Editor, I am doing it via a FORM AjaxEvent inside a mLoginForm. Can you send a sample (empty new mobile project) with this AjaxEvent ? Quote Link to comment Share on other sites More sharing options...
andyhill Posted July 26, 2023 Author Share Posted July 26, 2023 I added the ajax code to your skeleton sample and it worked so it obviously has to do with timing issues. I will need time to strip my project down and identify the timing/synchronisation problems - thank you for your input. 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted July 26, 2023 Share Posted July 26, 2023 34 minutes ago, andyhill said: I added the ajax code to your skeleton sample and it worked so it obviously has to do with timing issues. I will need time to strip my project down and identify the timing/synchronisation problems - thank you for your input. Good to hear that Thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.