Ajax
Ajax
is a droplab plugin that allows for retrieving and rendering list data from a server.
Usage
Add the Ajax
object to the plugins array of a DropLab.prototype.init
or DropLab.prototype.addHook
call.
Ajax
requires 2 config values, the endpoint
and method
.
-
endpoint
should be a URL to the request endpoint. -
method
should besetData
oraddData
. -
setData
completely replaces the dropdown with the response data. -
addData
appends the response data to the current dropdown list.
<a href="#" id="trigger" data-dropdown-trigger="#list">Toggle</a>
<ul id="list" data-dropdown><!-- ... --><ul>
const droplab = new DropLab();
const trigger = document.getElementById('trigger');
const list = document.getElementById('list');
droplab.addHook(trigger, list, [Ajax], {
Ajax: {
endpoint: '/some-endpoint',
method: 'setData',
},
});
Optionally you can set loadingTemplate
to a HTML string. This HTML string will
replace the dropdown list while the request is pending.
Additionally, you can set onError
to a function to catch any XHR errors.
Help and feedback
If there's something you don't like about this feature
To propose functionality that GitLab does not yet offer
To further help GitLab in shaping new features
If you didn't find what you were looking for
If you want help with something very specific to your use case, and can use some community support
POST ON GITLAB FORUM
If you have problems setting up or using this feature (depending on your GitLab subscription)
REQUEST SUPPORT
To view all GitLab tiers and features or to upgrade
If you want to try all features available in GitLab.com
If you want to try all features available in GitLab self-managed
If you spot an error or a need for improvement and would like to fix it yourself in a merge request
EDIT THIS PAGE
If you would like to suggest an improvement to this doc