Jump to content

SaveButtonEnhanced


bernhard
 Share

Recommended Posts

i really liked the "save + new" and "save + close" button back in my joomla days  :-X

here is the first version of a module to bring this functionality to processwire. i know there's the save actions module, but that's not exactly what i wanted...

module is alpha state

post-2137-0-91510000-1451746449.pngpost-2137-0-44696800-1451746818_thumb.pn

https://github.com/BernhardBaumrock/SaveButtonEnhanced

i have one problem where i need your help:

i want to submit the #ProcessPageEdit form via a jquery click() event: https://github.com/BernhardBaumrock/SaveButtonEnhanced/blob/master/SaveButtonEnhanced.module#L126

but unfortunately that does not submit the form reliably. sometimes it works, sometimes it doesn't. most of the time i need a second click.

also i was not able to trigger the click like this:

$('body').on('click', '.sbe_action', function() { console.log('clicked a sbe item'); });

it just did nothing :( does anyone know what is the problem here? would really appreciate it.

  • Like 4
Link to comment
Share on other sites

I like this option.

Regarding the intermittent click, maybe i glanced at it wrong, but aren't you already in the click event on line 128, and then executing another click on 131 for the same element?

Link to comment
Share on other sites

hi rick, thank you.

$($(this).data('submit')).click();

should trigger the click on the connected button (can be "publish" or "save without publish" or just "save"). wich button to click is stored in the data attribute called "submit". values are taken from the $actions array:

'buttons' => array('#submit_save', '#submit_save_unpublished')

so line 131 gets something like this:

$('#submit_publish').click();

at least that is the plan :)

Link to comment
Share on other sites

ok i found it! :) the clicks didn't work when i was editing any field, so i added a second click to remove focus from the input

// if any field has focus click the button twice
if($('input:focus').length > 0) $($(this).data('submit')).click();
$($(this).data('submit')).click();

some other things... i'm not sure how the dropdown is positioned. there is this code:

data-at='right bottom+1' 

i would prefer a left aligned dropdown like in the screenshots in the first post, but sometimes they are on the right side:

post-2137-0-15303700-1451752404_thumb.pn

another issue is when i click on the children tab it is anywhere in the middle:

post-2137-0-64770400-1451752433_thumb.pn

the module can be easily extended with other options - any ideas?

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...