Jump to content

Mobile: Remove Local Storage Key - Fails ?


andyhill

Recommended Posts

      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

Link to comment
Share on other sites

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_  ?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...