I have a div with a number of elements in it that I need to be disabled
(cant be clickable). I have comments being populated into this div, so I want the comments to still be readable, but no one can click, reply or like, until re-enabled.
Based on my research this cant be done in a formally correct way. I have gotten this, which works, but not when using window.onload(Or it works intermittently(:
window.onload = function(){
var isCommentsDisabled = '@Model.isCommentsDisabled';
alert(isCommentsDisabled);
if(isCommentsDisabled == 'True'){
$(".comments-container *").prop('disabled',true);
}
else if(isCommentsDisabled == 'False'){
$(".comments-container *").prop('disabled',false);
}
}
Below is the portion that needs to be disabled(This gets populated with all the elements on an ajax get:
<div id="comments-container" class="comments-container2">
</div>
EDIT
It seems what is posted into my container is the following(Hope this helps):
<div id="comments-container" class="comments-container2 jquery-comments" style="pointer-events: none;">
<div class="commenting-field main">
<div class="profile-picture round" style="background-image: url("https://viima-app.s3.amazonaws.com/media/public/defaults/user-icon.png");"></div>
<div class="textarea-wrapper">
<span class="enabled upload inline-button"><i class="fa fa-paperclip"></i><input type="file" data-role="none" multiple="multiple"></span>
<span class="close inline-button" style="display: none;">
<span class="left"></span>
<span class="right"></span>
</span>
<div class="textarea" data-placeholder="Add a comment" contenteditable="true" style="height: 8em;">sdfsdfsdfsdf<div><br></div><div><br></div><div><br></div><div><br></div></div>
<div class="control-row" style="display: none;">
<span class="send save highlight-background enabled">Send</span>
<span class="enabled upload"><i class="fa fa-paperclip"></i><input type="file" data-role="none" multiple="multiple"></span>
</div>
</div>
</div><ul class="navigation">
<div class="navigation-wrapper">
<li data-sort-key="newest" data-container-name="comments" class="active">Comments</li>
<li data-sort-key="oldest" data-container-name="comments"></li>
<li data-sort-key="popularity" data-container-name="comments"></li>
<li data-sort-key="attachments" data-container-name="attachments"><i class="fa fa-paperclip"></i>Attachments</li>
</div>
<div class="navigation-wrapper responsive">
<li class="title active">
<header>Comments</header>
</li><ul class="dropdown" style="display: none;">
<li data-sort-key="newest" data-container-name="comments" class="active">Comments</li>
<li data-sort-key="oldest" data-container-name="comments"></li>
<li data-sort-key="popularity" data-container-name="comments"></li>
</ul>
<li data-sort-key="attachments" data-container-name="attachments"><i class="fa fa-paperclip"></i>Attachments</li>
</div>
</ul><div class="data-container" data-container="comments">
<ul id="comment-list" class="main">
<li data-id="222" class="comment"><div class="comment-wrapper"><div class="profile-picture round" data-user-id="19b93ed9-5841-436a-bc6a-e19998d17b2d" style="background-image: url("https://viima-app.s3.amazonaws.com/media/public/defaults/user-icon.png");"></div><time data-original="2018-10-02">10/2/2018</time><div class="name"><span data-user-id="19b93ed9-5841-436a-bc6a-e19998d17b2d">Annebelle Lothering</span></div><div class="wrapper"><div class="content">I have entered the first Comment <input class="tag ping" type="button" data-role="none" value="@Cheyne Lothering" data-value="77e72598-8ed9-47e9-be28-1edbf6ad5656" data-user-id="77e72598-8ed9-47e9-be28-1edbf6ad5656"> What do you say about THAT!?</div><span class="actions"><button class="action reply" type="button">Reply</button><span class="separator">·</span><button class="action upvote highlight-font"><span class="upvote-count">2</span><i class="fa fa-thumbs-up"></i></button></span></div></div><ul class="child-comments"><li data-id="225" class="comment by-current-user"><div class="comment-wrapper"><div class="profile-picture round" data-user-id="46504a0d-8f29-43b7-a291-7827aa7bb04e" style="background-image: url("Cheyne&Annelie-48.jpg");"></div><time data-original="2018-10-02">10/2/2018</time><div class="name"><span data-user-id="46504a0d-8f29-43b7-a291-7827aa7bb04e">You</span></div><div class="wrapper"><div class="content">I agree with you <input class="tag ping" type="button" data-role="none" value="@Annebelle Lothering" data-value="19b93ed9-5841-436a-bc6a-e19998d17b2d" data-user-id="19b93ed9-5841-436a-bc6a-e19998d17b2d"> </div><span class="actions"><button class="action reply" type="button">Reply</button><span class="separator">·</span><button class="action upvote highlight-font"><span class="upvote-count">2</span><i class="fa fa-thumbs-up"></i></button><span class="separator">·</span><button class="action edit">Edit</button></span></div></div></li></ul></li>
<li data-id="226" class="comment"><div class="comment-wrapper"><div class="profile-picture round" data-user-id="c0cf6910-9724-40ba-934e-7c2f20164e08" style="background-image: url("https://viima-app.s3.amazonaws.com/media/public/defaults/user-icon.png");"></div><time data-original="2018-10-02">10/2/2018</time><div class="name"><span data-user-id="c0cf6910-9724-40ba-934e-7c2f20164e08">Annelie Lothering</span></div><div class="wrapper"><div class="content">This is a good idea, thanks!</div><span class="actions"><button class="action reply" type="button">Reply</button><span class="separator">·</span><button class="action upvote"><span class="upvote-count">0</span><i class="fa fa-thumbs-up"></i></button></span></div></div><ul class="child-comments"></ul></li>
</ul><div class="no-comments no-data"><i class="fa fa-comments fa-2x"></i><br>No comments</div>
</div><div class="data-container" data-container="attachments" style="display: none;"><ul id="attachment-list" class="main"></ul><div class="no-attachments no-data"><i class="fa fa-paperclip fa-2x"></i><br>No attachments</div></div><div class="droppable-overlay" style="display: none;"><div class="droppable-container"><div class="droppable"><i class="fa fa-paperclip fa-4x"></i><div>Drop files here</div></div></div></div><ul class="dropdown autocomplete" id="textcomplete-dropdown-2" style="display: none; left: 0px; position: absolute; z-index: 100;"></ul><ul class="dropdown autocomplete" id="textcomplete-dropdown-1" style="display: none; left: 0px; position: absolute; z-index: 100;"></ul>
</div>
So it works sometimes, but when I log out and log in with a new user, it doesnt seem to work.
Is there something else that can be done, or something other than a div that can be used ? I have even tried a fieldset
but that also does not work.
Appreciate any help.