empty list message on jquery sortableIs there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How to check whether a checkbox is checked in jQuery?Disable/enable an input with jQuery?Get selected text from a drop-down list (select box) using jQueryHow can I refresh a page with jQuery?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?
Can Bless or Bardic Inspiration help a creature from rolling a 1 on a death save?
Circle divided by lines between a blue dots
What is the fastest way to do Array Table Lookup with an Integer Index?
Norwegian refuses EU delay (4.7 hours) compensation because it turned out there was nothing wrong with the aircraft
Do liquid propellant rocket engines experience thrust oscillation?
Leaving a job that I just took based on false promise of a raise. What do I tell future interviewers?
To this riddle, I invite
Gas leaking in base of new gas range?
What are the end bytes of *.docx file format
Minimize taxes now that I earn more
Do things made of adamantine rust?
How to reference parameters outside of Apex Class that can be configured by Administrator
Pseudo Game of Cups in Python
What was an "insurance cover"?
How to fix folder structure in Windows 7 and 10
Did Apollo carry and use WD40?
How to deal with my team leader who keeps calling me about project updates even though I am on leave for personal reasons?
Apple Developer Program Refund Help
What is a Heptagon Number™?
Social leper versus social leopard
How to influence manager to not schedule team meetings during lunch?
Debussy as term for bathroom?
CDG baggage claim before or after immigration?
How do I extract code from an arduino?
empty list message on jquery sortable
Is there an “exists” function for jQuery?Add table row in jQueryHow do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How to check whether a checkbox is checked in jQuery?Disable/enable an input with jQuery?Get selected text from a drop-down list (select box) using jQueryHow can I refresh a page with jQuery?jQuery scroll to element“Thinking in AngularJS” if I have a jQuery background?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm working with jquery-sortable and I'm having some difficulty modifying the list container (ul) when it's been emptied or loaded empty. For example, If you have two containers:
- A collection list to drag from that always contains a few items.
- A destination list which loads empty (unless it is being edited and it will contain some list items but can be emptied by dragging them out of there
The empty container (ul) should display a message (i.e. nothing here) whenever it loads empty or it gets emptied on edit
I tried several approaches with no avail.
SAMPLE HTML FOR EMPTY CONTAINER
<ul id="mediaItemsListDest" class="playlist-items connectedSortable">
<!-- force a message in html -->
<p>Drag and drop an item from the list</p>
</ul>
DIFFERENT JQUERY APPROACHES
if( $("#mediaItemsListDest li").length >= 1 )
//remove it when the ul contains an li
$("#mediaItemsListDest p").css('display','none');
or
if( $("#mediaItemsListDest li").length === 0 )
//no li is found, display a message via jquery but don't add it as a <p> element in the html
$(this).html("Sorry, this is empty");
or
if( !$("#mediaItemsListDest").has("li").length )
$(this).html("Sorry, this is empty");
None of them worked. How else can I hijack this empty or emptied list?
Here's a testing fiddle for ya
DEMO
Thanks in advance
javascript jquery jquery-ui-sortable
add a comment
|
I'm working with jquery-sortable and I'm having some difficulty modifying the list container (ul) when it's been emptied or loaded empty. For example, If you have two containers:
- A collection list to drag from that always contains a few items.
- A destination list which loads empty (unless it is being edited and it will contain some list items but can be emptied by dragging them out of there
The empty container (ul) should display a message (i.e. nothing here) whenever it loads empty or it gets emptied on edit
I tried several approaches with no avail.
SAMPLE HTML FOR EMPTY CONTAINER
<ul id="mediaItemsListDest" class="playlist-items connectedSortable">
<!-- force a message in html -->
<p>Drag and drop an item from the list</p>
</ul>
DIFFERENT JQUERY APPROACHES
if( $("#mediaItemsListDest li").length >= 1 )
//remove it when the ul contains an li
$("#mediaItemsListDest p").css('display','none');
or
if( $("#mediaItemsListDest li").length === 0 )
//no li is found, display a message via jquery but don't add it as a <p> element in the html
$(this).html("Sorry, this is empty");
or
if( !$("#mediaItemsListDest").has("li").length )
$(this).html("Sorry, this is empty");
None of them worked. How else can I hijack this empty or emptied list?
Here's a testing fiddle for ya
DEMO
Thanks in advance
javascript jquery jquery-ui-sortable
add a comment
|
I'm working with jquery-sortable and I'm having some difficulty modifying the list container (ul) when it's been emptied or loaded empty. For example, If you have two containers:
- A collection list to drag from that always contains a few items.
- A destination list which loads empty (unless it is being edited and it will contain some list items but can be emptied by dragging them out of there
The empty container (ul) should display a message (i.e. nothing here) whenever it loads empty or it gets emptied on edit
I tried several approaches with no avail.
SAMPLE HTML FOR EMPTY CONTAINER
<ul id="mediaItemsListDest" class="playlist-items connectedSortable">
<!-- force a message in html -->
<p>Drag and drop an item from the list</p>
</ul>
DIFFERENT JQUERY APPROACHES
if( $("#mediaItemsListDest li").length >= 1 )
//remove it when the ul contains an li
$("#mediaItemsListDest p").css('display','none');
or
if( $("#mediaItemsListDest li").length === 0 )
//no li is found, display a message via jquery but don't add it as a <p> element in the html
$(this).html("Sorry, this is empty");
or
if( !$("#mediaItemsListDest").has("li").length )
$(this).html("Sorry, this is empty");
None of them worked. How else can I hijack this empty or emptied list?
Here's a testing fiddle for ya
DEMO
Thanks in advance
javascript jquery jquery-ui-sortable
I'm working with jquery-sortable and I'm having some difficulty modifying the list container (ul) when it's been emptied or loaded empty. For example, If you have two containers:
- A collection list to drag from that always contains a few items.
- A destination list which loads empty (unless it is being edited and it will contain some list items but can be emptied by dragging them out of there
The empty container (ul) should display a message (i.e. nothing here) whenever it loads empty or it gets emptied on edit
I tried several approaches with no avail.
SAMPLE HTML FOR EMPTY CONTAINER
<ul id="mediaItemsListDest" class="playlist-items connectedSortable">
<!-- force a message in html -->
<p>Drag and drop an item from the list</p>
</ul>
DIFFERENT JQUERY APPROACHES
if( $("#mediaItemsListDest li").length >= 1 )
//remove it when the ul contains an li
$("#mediaItemsListDest p").css('display','none');
or
if( $("#mediaItemsListDest li").length === 0 )
//no li is found, display a message via jquery but don't add it as a <p> element in the html
$(this).html("Sorry, this is empty");
or
if( !$("#mediaItemsListDest").has("li").length )
$(this).html("Sorry, this is empty");
None of them worked. How else can I hijack this empty or emptied list?
Here's a testing fiddle for ya
DEMO
Thanks in advance
javascript jquery jquery-ui-sortable
javascript jquery jquery-ui-sortable
asked Mar 28 at 15:03
LOTUSMSLOTUSMS
6,1967 gold badges34 silver badges80 bronze badges
6,1967 gold badges34 silver badges80 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
You need to handle on every list change the error message state so let's say we have the following HTML - example from your demo:
<ol id="mediaItemsListDest" class="simple_with_animation vertical">
<p>Drag and drop an item from the list</p>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Additionally I have extended with a function which is handling the message state, code is placed on initialization part of the application:
function handleMessage()
let liObjects = $('#mediaItemsListDest li');
let message = $('#mediaItemsListDest p');
console.log('length', liObjects.length);
console.log('message', message);
if (liObjects.length !== 0)
message.css('display', 'none');
else
message.css('display', 'inline');
handleMessage();
This function needs to be called in onDrop event:
onDrop: function ($item, container, _super)
// code part removed but you can find in your demo
handleMessage();
I did a quick test and it was working fine. I hope this one is helping, let me know if you need more information.
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400859%2fempty-list-message-on-jquery-sortable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to handle on every list change the error message state so let's say we have the following HTML - example from your demo:
<ol id="mediaItemsListDest" class="simple_with_animation vertical">
<p>Drag and drop an item from the list</p>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Additionally I have extended with a function which is handling the message state, code is placed on initialization part of the application:
function handleMessage()
let liObjects = $('#mediaItemsListDest li');
let message = $('#mediaItemsListDest p');
console.log('length', liObjects.length);
console.log('message', message);
if (liObjects.length !== 0)
message.css('display', 'none');
else
message.css('display', 'inline');
handleMessage();
This function needs to be called in onDrop event:
onDrop: function ($item, container, _super)
// code part removed but you can find in your demo
handleMessage();
I did a quick test and it was working fine. I hope this one is helping, let me know if you need more information.
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
add a comment
|
You need to handle on every list change the error message state so let's say we have the following HTML - example from your demo:
<ol id="mediaItemsListDest" class="simple_with_animation vertical">
<p>Drag and drop an item from the list</p>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Additionally I have extended with a function which is handling the message state, code is placed on initialization part of the application:
function handleMessage()
let liObjects = $('#mediaItemsListDest li');
let message = $('#mediaItemsListDest p');
console.log('length', liObjects.length);
console.log('message', message);
if (liObjects.length !== 0)
message.css('display', 'none');
else
message.css('display', 'inline');
handleMessage();
This function needs to be called in onDrop event:
onDrop: function ($item, container, _super)
// code part removed but you can find in your demo
handleMessage();
I did a quick test and it was working fine. I hope this one is helping, let me know if you need more information.
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
add a comment
|
You need to handle on every list change the error message state so let's say we have the following HTML - example from your demo:
<ol id="mediaItemsListDest" class="simple_with_animation vertical">
<p>Drag and drop an item from the list</p>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Additionally I have extended with a function which is handling the message state, code is placed on initialization part of the application:
function handleMessage()
let liObjects = $('#mediaItemsListDest li');
let message = $('#mediaItemsListDest p');
console.log('length', liObjects.length);
console.log('message', message);
if (liObjects.length !== 0)
message.css('display', 'none');
else
message.css('display', 'inline');
handleMessage();
This function needs to be called in onDrop event:
onDrop: function ($item, container, _super)
// code part removed but you can find in your demo
handleMessage();
I did a quick test and it was working fine. I hope this one is helping, let me know if you need more information.
You need to handle on every list change the error message state so let's say we have the following HTML - example from your demo:
<ol id="mediaItemsListDest" class="simple_with_animation vertical">
<p>Drag and drop an item from the list</p>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Additionally I have extended with a function which is handling the message state, code is placed on initialization part of the application:
function handleMessage()
let liObjects = $('#mediaItemsListDest li');
let message = $('#mediaItemsListDest p');
console.log('length', liObjects.length);
console.log('message', message);
if (liObjects.length !== 0)
message.css('display', 'none');
else
message.css('display', 'inline');
handleMessage();
This function needs to be called in onDrop event:
onDrop: function ($item, container, _super)
// code part removed but you can find in your demo
handleMessage();
I did a quick test and it was working fine. I hope this one is helping, let me know if you need more information.
edited Mar 28 at 15:38
answered Mar 28 at 15:33
norbitrialnorbitrial
6994 silver badges13 bronze badges
6994 silver badges13 bronze badges
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
add a comment
|
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Worked great! There is a ghost placeholder that I can't get rid of or access. The dev console shows an empty UL but the there is something in there when the container is emptied creating an unnecessary space after emptying. But I'm guessing that is necessary for the script to "hook" on to something ---a target, i you will. I wish I could at least make it go away with css so it dosn't shift my list. But that's unrelated to this question. Your answer worked out great. Thanks
– LOTUSMS
Mar 28 at 15:47
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
Great, thanks! :)
– norbitrial
Mar 28 at 15:55
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
FIxed that issue by modifying your css(); with addClass() and removeClass() and sprinkled a little flexbox css on top...Ready to eat!
– LOTUSMS
Mar 28 at 15:57
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
Oh, cool, nice job!
– norbitrial
Mar 28 at 16:02
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400859%2fempty-list-message-on-jquery-sortable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown