Jump to content

unselect/clear button for PageListSelect


bernhard
 Share

Recommended Posts

when a PageListSelect is populated it looks like this:

post-2137-0-13256600-1429187596_thumb.pn

if you want to clear the value of this field rather than changing the referenced page, you have to do lots of clicking if your selected page is somewhere down the tree:

post-2137-0-18771800-1429187502_thumb.pn

it would be great to have a "clear" button right beside the "change" button

post-2137-0-89855200-1429187556_thumb.pn

  • Like 7
Link to comment
Share on other sites

i really respect this approach but i think the possibility should at least be there after clicking on "change" so it would appear beside "cancel" or like the new pageDelete floating right.

for my project this behaviour is a nightmare... unfortunately i'm not skilled enough to make this on my own, but i thought maybe this would be a 5-min-thing for ryan or any of the other gurus :)

Link to comment
Share on other sites

  • 1 month later...
  • 5 months later...

/site/ready.php 

$wire->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event){
    $process = $event->object;
    $page = $process->getPage();
    $config = wire('config');

    if($page->template == 'basic-page') {
        $config->scripts->append($config->urls->templates . 'scripts/pagefieldclearbutton.js');
    }
});

/site/scripts/pagefieldclearbutton.js

$(window).load(function() {
    $('ul.PageListActions').append('<li class="PageListActionSelect PageFieldClearButton"><a href="#">Unselect</a></li>');

    $('.PageFieldClearButton').click(function() {
        $(this).parent().siblings('p.PageListSelectName').html('');
        $('#Inputfield_pageselect').val('');
    });
});

working starting point. maybe someone wants to take this further...

post-2137-0-15290600-1448448754_thumb.gi

as you can see it jumps to the pagetop for now :(

  • Like 2
Link to comment
Share on other sites

  • 1 month 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...