Last active
August 29, 2015 14:18
-
-
Save heristop/2eb5e937307d1a7c69d9 to your computer and use it in GitHub Desktop.
[SonataAdmin] Show the save button on scroll down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
/** Update button **/ | |
if (null !== location.pathname.match(/\/edit/)) { | |
$(window).scroll(function() { | |
if ($(window).height() + $(window).scrollTop() > $(document).height() - 10 || $(this).scrollTop() < 100) { | |
$('#save-button').fadeOut(); | |
} | |
else { | |
$('#save-button').fadeIn(); | |
} | |
}); | |
$('#save-button').bind('click', function() { | |
$('form').submit(); | |
}); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'SonataAdminBundle::standard_layout.html.twig' %} | |
{% block javascripts %} | |
{{ parent() }} | |
<script src="{{ asset('bundles/mybundle/js/sonata_edit.js') }}" type="text/javascript"></script> | |
{% endblock %} | |
{% block sonata_top_nav_menu %} | |
<div class="navbar-custom-menu"> | |
<ul class="nav navbar-nav"> | |
<li class="dropdown"> | |
<div id="save-button"> | |
<button type="submit" class="btn btn-success" name="btn_update_and_edit"> | |
<i class="fa fa-save"></i> | |
</button> | |
</div> | |
</li> | |
<li class="dropdown"> | |
<a class="dropdown-toggle" data-toggle="dropdown" href="#"> | |
<i class="fa fa-plus-square fa-fw"></i> <i class="fa fa-caret-down"></i> | |
</a> | |
{% include admin_pool.getTemplate('add_block') %} | |
</li> | |
<li class="dropdown user-menu"> | |
<a class="dropdown-toggle" data-toggle="dropdown" href="#"> | |
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i> | |
</a> | |
<ul class="dropdown-menu dropdown-user"> | |
{% include admin_pool.getTemplate('user_block') %} | |
</ul> | |
</li> | |
</ul> | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment