Jump to content
pconkie

Site events that widgets can detect

Recommended Posts

I need to do something in my widget when the site is saved.  I can't find an appropriate site event for this! These are the one's I've found:

'widget.live': function(el, ev, data) {
	console.log("live mode");
}

'widget.edit': function(el, ev, data) {
	console.log("edit mode");
}

'broadcast.selectedUser': function(el, ev, data) {
	console.log("broadcast fired");
},

'widget.updated': function(el, ev, data) {
	console.log("updated");
}

'widget.save': function(el, ev, data) {
	console.log("saved");
}

The last two events never seem to output anything - do they actually do anything?

widget.save might be the event I need, but doesn't work!

Any thoughts @Graham Quince @adamw ?

Share this post


Link to post
Share on other sites
16 hours ago, pconkie said:

I need to do something in my widget when the site is saved.  I can't find an appropriate site event for this! These are the one's I've found:


'widget.live': function(el, ev, data) {
	console.log("live mode");
}

'widget.edit': function(el, ev, data) {
	console.log("edit mode");
}

'broadcast.selectedUser': function(el, ev, data) {
	console.log("broadcast fired");
},

'widget.updated': function(el, ev, data) {
	console.log("updated");
}

'widget.save': function(el, ev, data) {
	console.log("saved");
}

The last two events never seem to output anything - do they actually do anything?

widget.save might be the event I need, but doesn't work!

Any thoughts @Graham Quince @adamw ?

FYI.... Quincy's skiving...  some kind of man flu!!! :P

Share this post


Link to post
Share on other sites

I think widget.updated is called whenever a widget preference is changed, which then automatically calls widget.save - which is why you are probably not seeing anything happening when you're saving a site. I'll have a look in the code now, but if you can give me an example of the sort of thing you're trying to do, then it might steer me in the right direction :)

 

Share this post


Link to post
Share on other sites

@pconkie - try listening for:

site.updated

We seem to fire off an event by that name when a site is saved. That might get you what you're after.

  • Thanks 1

Share this post


Link to post
Share on other sites

I added the following to my widget but no luck....

'site.updated': function(el, ev, data) {
  console.log("saved?");
},

I'm trying to get the widget instance unique identifier  e.g  data-content-uuid="987E090D200280562B9EDF3ACFA5F00A665BA5DC8CC6ECD5"

I can get this using

this.options.content_uuid

However, before the site is saved the data-content-uuid looks more like this: e.g  data-content-uuid="content_7643678655467".  This appears to be temporary as when the site is saved it is replaced with one like above that never again changes.  I need the permanent one. So i have a message that is displayed after a new widget instance is dragged onto a site that says "please save the site to activate this widget".  Following a save the dom is updated with the permanent uuid and then i want to do stuff with it.  

Can i 'listen' for a particular attribute change if the widget can not hear the site saved event?

Share this post


Link to post
Share on other sites

Related to this question @adamw

I'm trying to use the frog datastore api. How do I allow anonymous users (not logged in) access to the get (I don't want create, update or delete, just get).  I'm seeing an access denied message when interacting with a page that is shared publicly while i'm not logged in. How did you get around this issue for your very useful visitcount widget (or does it not work for anonymous views?)

Thanks  

Share this post


Link to post
Share on other sites
5 minutes ago, pconkie said:

Related to this question @adamw

I'm trying to use the frog datastore api. How do I allow anonymous users (not logged in) access to the get (I don't want create, update or delete, just get).  I'm seeing an access denied message when interacting with a page that is shared publicly while i'm not logged in. How did you get around this issue for your very useful visitcount widget (or does it not work for anonymous views?)

Thanks  

It doesn't work for non-logged in users - as for the datastore, I'm sure someone else asked this before and we came up with a way to sort this, but I've forgotton now what we were going to do! I'll have a think and get back to you :)

 

Share this post


Link to post
Share on other sites

Looks like Conkies cooking up another of his specials.. :D

Share this post


Link to post
Share on other sites
On 12/03/2019 at 11:57, adamw said:

It doesn't work for non-logged in users - as for the datastore, I'm sure someone else asked this before and we came up with a way to sort this, but I've forgotton now what we were going to do! I'll have a think and get back to you :)

 

Any thoughts? @adamw 

Share this post


Link to post
Share on other sites
On 15/03/2019 at 18:10, pconkie said:

Any thoughts? @adamw 

Yeah, I have an idea - when you're not logged in you are technically authing as a special user in Frog. It might be possible to give this user the roles to access the datastore - but I have no idea if it will work - I've never tested it before!

Share this post


Link to post
Share on other sites
On 12/03/2019 at 11:42, pconkie said:

I added the following to my widget but no luck....


'site.updated': function(el, ev, data) {
  console.log("saved?");
},

I'm trying to get the widget instance unique identifier  e.g  data-content-uuid="987E090D200280562B9EDF3ACFA5F00A665BA5DC8CC6ECD5"

I can get this using


this.options.content_uuid

However, before the site is saved the data-content-uuid looks more like this: e.g  data-content-uuid="content_7643678655467".  This appears to be temporary as when the site is saved it is replaced with one like above that never again changes.  I need the permanent one. So i have a message that is displayed after a new widget instance is dragged onto a site that says "please save the site to activate this widget".  Following a save the dom is updated with the permanent uuid and then i want to do stuff with it.  

Can i 'listen' for a particular attribute change if the widget can not hear the site saved event?

I think I see what you're saying and there could be a way around this in your case. You can test to see if a widget has been saved by looking at the data-content-uuid and seeing if it is a valid Frog UUID. For example:

Frog.Utilities.Validate.uuid("987E090D200280562B9EDF3ACFA5F00A665BA5DC8CC6ECD5")

Will return true, whereas 

Frog.Utilities.Validate.uuid("content_7643678655467")

Will return either false or undefined.

If it has a valid UUID then the widget has been saved, else it hasn't and you can display your 'please save this widget' message.

  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, adamw said:

I think I see what you're saying and there could be a way around this in your case. You can test to see if a widget has been saved by looking at the data-content-uuid and seeing if it is a valid Frog UUID. For example:


Frog.Utilities.Validate.uuid("987E090D200280562B9EDF3ACFA5F00A665BA5DC8CC6ECD5")

Will return true, whereas 


Frog.Utilities.Validate.uuid("content_7643678655467")

Will return either false or undefined.

If it has a valid UUID then the widget has been saved, else it hasn't and you can display your 'please save this widget' message.

Great!

But after the widget has been saved and the UUID is now valid, what event can I use to re-check the UUID? Or can I 'watch' the tag attribute and use the change to trigger the code?

Share this post


Link to post
Share on other sites
widget.live

This is triggered whenever the widget is rendered on a page and not in edit mode. So you can put your check in there.

Share this post


Link to post
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...