the docs explain how data out of webview, not how pass data into it.
right now, set dummy variable , return correct url in open callback:
function onsettingsopen(e) { var options = settings.option(); return url_root + '/settings?options=' + encodeuricomponent(json.stringify(options)); } settings.config( { url: 'dummy' }, onsettingsopen, onsettingsupdated ); (i discovered trial-and-error. wasn't mentioned anywhere in docs.)
if pass url directly settings.config (instead of calculating each time), happens:
- open settings page → webview gets data.
- make changes , save → app gets new data.
- open settings page again → webview gets stale data.
settings passes options webview same way expected passed pebble.js; is, suffixed after hash '#' symbol uri encoded json object. in configuration page, use
json.parse(decodeuricomponent(window.location.hash.substr(1))) to obtain options. can see having window.location displayed debug output in configuration page. assuming have jquery-like:
$('.some-element').text(window.location) if configuration page served dynamic server, won't receive options since hash sections of urls aren't sent server. therefore, pass options server, url has constructed. while seems huge limitation, chosen way because doesn't force query format. example formats settings in single query param or options spread apart multiple query parameters.
with said, perhaps accept template url automate second largest use case, settings in single query param. like
// non-functioning feature request settings.config({ url: 'http://server/settings?options=${options}' }, ...)
Comments
Post a Comment