Checkboxes do not work in my custom made module - dotnetnuke

I have a site made in ASP.NET which I turned into a DotNetNuke module. But now when I try to check the checkboxes it doesn't work.

add the class "normalCheckBox" to your checkbox and DNN will ignore it. ej:
<input type="checkbox" class="normalCheckBox">

The nice people who made DotNetNuke have a special kind of humor. It turns out that checkboxes used on my site are hidden by DotNetNuke and replaced by an image of a checkbox. The reason behind this is unclear to me.
Just take a look at the HTML:
<label style="display: inline-block;">
<input type="checkbox" id="copyAllSettingsCheckBox" name="copyallcheckbox" title="Copy all settings" style="position: absolute; z-index: -1; visibility: hidden;">
<span class="dnnCheckbox">
<span class="mark">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRFAAAAAAAApWe5zwAAAAF0Uk5TAEDm2GYAAAAMSURBVHjaYmAACDAAAAIAAU9tWeEAAAAASUVORK5CYII=">
</span>
</span>
Include any additional settings.
</label>
To fix this I used the code shown below. This effectively cleans up the stuff added by DotNetNuke. Just put it at the end of your javascript.
$('.dnnCheckbox').remove();
$(':checkbox').removeAttr('style');

I'm having similar problems.
In my case I am using a dialog/popup, and the cause of the checkbox not working seems to be the z-index being -1 (negative one).
HOWEVER it seems that the z-index of the checkbox isn't always set to -1.
For example, as I have mine in a dialog (popup) box, initially the z-index is set to -1 (which seems to work).
When I open the dialog with a button click, the z-index is set to 1001 (which also, seems to work).
However with the checkbox contained in an update panel, the postback renders the checkbox's z-index back to -1 (which doesn't work, as the checkbox is underneath the dialog box).
In conclusion - check if z-index of the element containing the checkbox (recursively) is greater than the checkbox z-index, as this might be the cause of it not working (elements without a z-index seem to work with the checkbox fine).
Bit of a hacky fix:
I added some jQuery onload to bring checkbox's z-index above it's parent (in this case the jQuery dialog)
This will get all the inputs with a z-index of -1 within the parent element, and set their z-index 1 above the parent
//the id being the parent element that has the higher z-index
function FixInputZIndex(id){
var element = $('#' + id);
$('#' + id + ' input').filter(function () { return $(this).css('z-index') < 0; }).css('z-index', element.css('z-index') + 1);
}

Related

How can I reliably set focus on elements inside of my AngularStrap tooltip?

My team uses AngularStrap to integrate Bootstrap modals (e.g. popover, tooltip, etc.) into our Angular 1.5 app. Unfortunately, I have found it extremely difficult to reliably set focus on elements inside of these modals because of the funky way in which AngularStrap shows them. This logic lives here:
https://github.com/mgcrea/angular-strap/blob/b13098d9d658da9408930b25f79182df920718d2/src/tooltip/tooltip.js
Essentially, all AngularStrap modals start off in the hidden state:
// Set the initial positioning. Make the tooltip invisible
// so IE doesn't try to focus on it off screen.
tipElement.css({top: '-9999px', left: '-9999px', right: 'auto', display: 'block', visibility: 'hidden'});
They are then made visible in response to some internal Angular requestAnimationFrame service callback:
$$rAF(function () {
// Once the tooltip is placed and the animation starts, make the tooltip visible
if (tipElement) tipElement.css({visibility: 'visible'});
...
});
Unfortunately, this means that at the time all of the tooltip's DOM elements are constructed the tooltip is typically not yet visible and any attempts to call focus() on these elements fail. Do note that in my experience this happens intermittently (~20% of the time for me).
I tried disabling animations on the tooltip but it doesn't seem to be smart enough to skip this whole hidden/visible dance in that case. I could obviously try something super hacky (e.g. use an arbitrary timeout before attempting to set focus) but I am looking for a more reliable option.
Why not use the onShow event? It is documented a little bit wrong, but you can attach a handler that focus elements to bs-on-show. Furthermore you could make the handler generic, looking for an element with a focus-me attribute and focus that :
<div bs-popover
data-content='this input should be focused: <input type="text" focus-me>'
data-placement="bottom"
bs-on-show="setFocus"
data-html="true">
click me to show popover
</div>
<div bs-tooltip
data-title='this input should be focused: <input type="text" focus-me style="color:#000;">'
data-placement="bottom"
data-trigger="click"
bs-on-show="setFocus"
data-html="true">
click me to show tooltip
</div>
generic handler
$scope.setFocus = function(e) {
e.$element.find('[focus-me]').focus()
}
http://plnkr.co/edit/3wTinmNb5zsKnfUZQ9tT?p=preview

UI Grid Custom Checkbox styling

I am attempting to do some styling with the checkboxes in UI-Grid and it doesn't seem to be working properly. Notice the checkbox is still appearing underneath my styling overlay, and clicking on the 3rd checkbox seems to activate the overlay checkbox style.
Is there any way to replace the checkbox appearing in the column with my overlay and use that instead? Or does anyone have an idea to get this working properly?
http://plnkr.co/edit/fMMq71849pxE0NLcfuVJ
cellTemplate: '<div class="ui-grid-cell-contents">' +
' <input type="checkbox" class= "Check" id="Check" name="select_item" value = "true" ng-model="row.entity.ValidateProvider"/>' +
' <label for="roundedOne" />' +
' </div>'
I want to get them looking like the 4th from the top on this site:
http://cssdeck.com/labs/css-checkbox-styles
There is no easy way to do that.
In UI Grid, we usually uses blur event of HTML input control to end cell edit, which should be the best user experience. However currently there is no suitable CSS support to style custom checkbox, and to properly dispatch blur event at the same time. In the example mentioned, you can see the css rule to make `blur' impossible:
input[type=checkbox] { visibility: hidden; }
There is a non-standard css property appearance to use, which can work at this time, instead of visibility and others, but needs careful test on browsers. No support on any IE.
Also, editableCellTemplate should be used rather than cellTemplate for edit.

Angular UI Bootstrap Responsive menu - closing menu when clicking off it?

I've successfully created a responsive menu using Angular UI Bootstrap. The problem is:
When the responsive menu is open it can only be closed by re-clicking the toggle. Clicking anywhere else on the page keeps the menu open, which is undesirable for the site I'm building.
I'm looking for this functionality:
Clicking anywhere except the menu should close the menu, not toggle it.
How would one go about achieving this? I tried setting an ng-click on the html or body elements and seeing if that would work, but it didn't.
This actually fairly simple to solve with a little extra CSS and an added div.
Plunker Demo
The mechanics of this solution are pretty straightforward: Add an extra div to the navbar markup that serves as a clickable backdrop when the menu is expanded.
CSS:
.backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: transparent;
z-index: -1;
}
To make sure that the backdrop covers the entire viewport, you'll use position: fixed and set the top, right, bottom and left properties to 0. Then you'll need to make sure that the backdrop doesn't cover the menu, rendering your menu items un-clickable. To do this, you need to set its z-index to -1. Finally, to make sure it's 'clickable' you need to give it a background. Setting the background-color to transparent makes sure that it doesn't obscure any of the navbar elements.
The next thing you need to do is ensure that the backdrop element is only displayed when the menu is expanded, otherwise it would cover your body content and make it impossible to interact with any of the content. The cool thing is that the ngClass directive makes this simple. You can use the isCollapsed scope variable to determine when to add the backdrop class by setting the expression to isCollapsed === false. Lastly, add an ng-click attribute to close the menu. So, the markup looks like the following:
MARKUP:
<div ng-class="{backdrop: isCollapsed === false}" ng-click="isCollapsed = !isCollapsed"></div>
When the backdrop class is not added, the div--which has no content--will naturally collapse to a height of 0, so there's actually no need to hide or show it.
Just remember that the backdrop div has to be added to the same element that is handled by your controller that manages the collapse state of the menu. If it can't access the isCollapsed scope variable, it won't display and the ng-click event will have no effect.
You can easily improve this by creating a simple custom directive, so that you don't have to add the div in your markup. Just set the scope property of the directive to true so that the directive has access to the parent isCollapsed variable.

How to show popover that is hiding behind navbar

I am new to Bootstrap and Angular. In my webpage there is a button and i am providing a popover for a span like this
<span popover="Download Project History" popover-trigger="mouseenter" tooltip-placement="top" style="padding: 5px" translate="DOWNLOAD">DOWNLOAD</span>
But its getting hidden under navbar.
Based on my googling i found to provide data-container="body" in the html element. But its not working too.
Can anyone please help me?
Thanks
I had a similar problem where the popover was hidden behind overflow content and adding the following attribute fixed it:
popover-append-to-body="true"
tooltip-append-to-body="true"
attaches the tooltip to the body and makes it visible.
You need to override the z-index value, you can have a look for the default values (for navbar and popover) in original Bootstrap's CSS file. In my case this helped:
.popover {
/* just in case it would overlap with fixed navbar, then show this over the navbar. Original value 1010, value for navbar is 1030 */
z-index: 1030;
}

How to prevent animation from running on element that is initially hidden?

My question is similar to this one and this one, but involves the new animations in AngularJS 1.2.0.
Basically, I have a bunch of elements on my signup page that are initially hidden and only displayed when a particular form element is invalid (they point to the invalid form element and display a message like "password needs to be at least 8 characters"). These messages fade in and out as they are shown/hidden.
But as soon as the signup page is displayed the elements are visible and fade out. They are briefly visible (they "blink" or "flash" on the screen, as is the case in situations where ng-cloak is necessary).
Here's a plunker to demonstrate the behaviour that I'm experiencing. In this plunker I have set up a basic route (the "login" page) that contains a box and a button that toggles the box's visibility. Notice how the box fades out when you click run? It should just be hidden. (I've deliberately set the animation to be slow so you can see the animation occurring).
How can I stop the animation from occurring initially?
What I've tried:
Set ng-cloak on the animating elements.
Use ng-cloak with the display: none !important rule added. (See this)
Setting display: none on the element, as if it were an "initial setting" for the element. (See this)
Interestingly, this plunker behaves properly and the animation doesn't occur initially. This plunker doesn't use routing and the controller is set explicitly on the body tag. I want to use routing though.
There's a problem with the version of angular you are using. Angular animate changed a lot I think in 1.2 so try this:
<script src="http://code.angularjs.org/1.2.14/angular.min.js"></script>
<script src="http://code.angularjs.org/1.2.14/angular-animate.min.js"></script>
<script src="http://code.angularjs.org/1.2.14/angular-route.min.js"></script>
Check it out, I've forked your plunker here
http://plnkr.co/edit/Mchjx51GREGU2Gj0NBXX?p=preview

Resources