php-debugbar
php-debugbar copied to clipboard
Selecting first dataset to display by default in the debugbar UI
On a page with multiple ajax calls, I want the first dataset (First request) to be selected by default. Right now the last request is selected by default.
How can we achieve this ?
should be very easy and a good default. will change that
Or a checkbox/toggle, to indicate you want to load the latest requests, or stay on the first on. When loading a page, I usually want to see the real page and not the ajax calls. But when I click on something after a few seconds, I'd rather see the new requests. Not really sure what would be the best default :P
I would select the first one on load but subsequent ajax calls are automatically selected. Is that ok?
Maxime
On Thu, Apr 24, 2014 at 9:57 AM, Barry vd. Heuvel [email protected]:
Or a checkbox/toggle, to indicate you want to load the latest requests, or stay on the first on. When loading a page, I usually want to see the real page and not the ajax calls. But when I click on something after a few seconds, I'd rather see the new requests. Not really sure what would be the best default :P
— Reply to this email directly or view it on GitHubhttps://github.com/maximebf/php-debugbar/issues/120#issuecomment-41290102 .
What does "subsequent ajax calls" mean exactly ? After page load and onload ajax calls, if I click somewhere and an ajax call happens, then it should probably be selected automatically. Anything is fine actually. Important thing being that real page should be visible by default on page load. thanks.
I was looking into that and it seems harder than it looked at first. I don't know if an ajax call is triggered on page load or due to a click event so I cannot know when to auto-show a request or not. To know the origin of an ajax request, it would be needed to indicate everywhere whether to show it or not which would be cumbersome. At the moment I'm leaving the default as is but adding the possibility to show or not a request when it is added to the debugbar in the api. The checkbox idea will propably be the best option I think.
:+1: for the checkbox. If it is checked, it stays on the currently selected item in the select, otherwise it shows up the latest received dataset.
Has this been fixed yet? This is a really frustrating problem on pages that have constant automatic AJAX requests.
Has this been fixed yet?
This bug was bothering me, so I made a quick and dirty solution that overrides the js method addDataSet:
<script>
// Copied from the source with a single line commented out
PhpDebugBar.DebugBar.prototype.addDataSet = function(data, id, suffix) {
var label = this.datesetTitleFormater.format(id, data, suffix);
id = id || (getObjectSize(this.datasets) + 1);
this.datasets[id] = data;
this.$datasets.append($('<option value="' + id + '">' + label + '</option>'));
if (this.$datasets.children().length > 1) {
this.$datasets.show();
}
// The below line was commented out to prevent automatic switching to ajax requests
// this.showDataSet(id);
return id;
};
</script>
If you place the above script below your $renderer->render() output, it will only take effect after the initial page load. So, if you have stacked requests from a redirect it will show the latest one, but then it won't switch automatically anymore for future ajax requests.
As far as I can see it manageable with autoShow value now.