This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
How to refresh Webview on $pull
Camilo edited this page May 22, 2022
·
3 revisions
This is a sample code that demostrates how you can use the $pull
event to refresh a webview.
A simple website that shows the current timestamp. Put this file inside the file
directory.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
Refreshed at: <span id="time"></span>
<script type="text/javascript">
document.getElementById("time").innerHTML = (new Date()).toString()
</script>
</body>
</html>
Note the addition of an empty sections
("sections": [{"items": [{}]}],
) . Without it the $pull
will not trigger properly.
Also you must check that SWTableViewCell.m
line 94 contains the fix of if (self.subviews.count > 0 …
or it will crash. Update your pods :).
{
"$jason": {
"head": {
"title": "Reload webpage on pull",
"actions": {
"$pull": {
"type": "$agent.request",
"options": {
"id": "$webcontainer",
"method": "(() => { window.location.reload(); $agent.response(); })",
"params": []
}
}
}
},
"body": {
"sections": [{"items": [{}]}],
"style": {
"border": "rgba(0,0,0,0)"
},
"background": {
"type": "html",
"url": "file://web.html",
"action": {
"type": "$default"
}
}
}
}
}
On newer version of Jasonette iOS
you can use the pull
option
to achieve the same
{
"$jason": {
"head": {
"title": "Reload webpage on pull",
"actions": {
"$pull": {
"type": "$agent.request",
"options": {
"id": "$webcontainer",
"method": "(() => window.location.reload())",
"params": []
}
}
}
},
"body": {
"style": {
"border": "rgba(0,0,0,0)"
},
"background": {
"type": "html",
"url": "file://web.html",
"options": {
"pull": true
},
"action": {
"type": "$default"
}
}
}
}
}
- Telegram: https://t.me/jasonelle
- Website: https://jasonelle.com
- Additional: https://jasonelle-archive.github.io/docs/legacy/