bootstrap modal removes scroll bar

When I trigger a modal view in my page it triggers the scroll bar to disappear. It’s an annoying effect because the background page starts moving when the modal moves in / disappears. Is there a cure for that effect?


This is a feature, class modal-open gets added to the HTML body when you show the modal, and removed when you hide it.

This makes the scrollbar disappear since the bootstrap css says

.modal-open {
    overflow: hidden;

You can override this by specifying

.modal-open {
    overflow: scroll;

in your own css.


Sharing code between AngularJS and Nodejs

What is the best way of sharing code between frontend and backend using javascript, specifically saying between nodejs and angularjs?

Thing is that we are using same enums and constant values such as error codes in both backend and frontend. Right now we just copy&paste each change to both platform which isn’t a good solution. There are also some services that could be shared.

I have seen libraries such as browserify; but thats not exactly what I am looking for. I am looking for a solution similar to maven dependency in java. In java, libraries can be shared easily using maven, whereas I can’t find a similar way of doing that in javascript. Is there a way to isolate these services and give them as dependency to nodejs using npm and to angularjs using bower independently? Or what are the ways for sharing the same code between frontend and backend?


There are several ways to do this. The first is that you can make a new package which is required via bower for the front-end code and via npm for the backend code. I have several packages published to both systems.

Install with Bower — information on how to install modules that aren’t in the registry

NPM Install docs — all the ways to install with npm (private github with auth: git+ssh://[org]/[repo])

Just create a new module with your shared data and install it using both package managers. Both of them allow you to install an unpublished module so if it’s private data you can keep it as such.

If your front end requires require.js you can use something like amdefine to make it available to your node backend, or if you’re just using legacy window code you can do something like:

var mydata = {};

if(typeof window !== 'undefined'){
    window.mydata = mydata;
} else {
     module.exports = mydata;

If you are sharing a lot of data though I highly recommend looking into browserify to write your entire codebase in commonjs and using browserify to generate your client bundle. There is a laundry list of resources about using browserify, including stuff on how to use browserify and angular together


Opensaml error receiving correct unmarshaller

I am running this code at opensaml2.6

Element metadataRoot = document.getDocumentElement();

// Unmarshall
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);
if (unmarshaller == null) {
    System.out.println("Error receiving unmarshaller for this document.");

For the document

<?xml version="1.0" encoding="UTF-8"?><saml2:EncryptedAssertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">

Unmarshaller return a null, Can you help me to undertand how are the criterias to lookup the correct Unmarshaller and how this works at opensaml?


I found that there is not unmarshallers register as there is not initialization in the library:

Important piece of code:

// Initialize the library

Checking for Power Saver Mode programmatically

I have written an app (AutoWifiSwitch) and one of the features I plan to add is automatically disabling the wifi scanning service in my app if power saving mode is enabled.

I know Android L is supposed to have Battery Saving implemented (previously HTC and Samsung would add the features themselves to the software). Presumably this now means Google will have added some sort of API for it. Ideally there would be a new action added so I could listen for that.

I would also like to know if the above is possible with HTC/Samsung APIs and if so, how do I use them.

I’ve been searching everywhere for the above questions but had absolutely no luck, the app SecureSettings (an addon for Tasker) is able to hook into the HTC/Samsung APIs to enable the power saver anyway, I’m not quite sure how they do it.

Edit: The power saver value can be gotten from the PowerManager in Android L, not sure if there is an Action for it though.


I’ve eventually figured out how to do this with HTC and Samsung devices. Both store their power manager settings in Settings.System.

HTC (Sense) uses the key user_powersaver_enable. Samsung (Touchwiz) uses the key psm_switch.

Both store the boolean as a String, “0” being false and “1” being true. You can then listen for changes using a ContentObserver like so (requires API level 16 or higher):

getContentResolver().registerContentObserver(Settings.System.CONTENT_URI, true, new ContentObserver(){
  public void onChange(boolean selfChange, Uri uri){
    super.onChange(selfChange, uri);
    String key = uri.getPath();
    key = key.substring(key.lastIndexOf("/") + 1, key.length());

    if (key.equals("user_powersaver_enable") || key.equals("psm_switch")){
      boolean batterySaverEnabled = Settings.System.getString(getContentResolver(), key).equals("1");
      // do something

However this will only be applicable until Android L is release, when L is released HTC and Samsung will likely move over to the AOSP battery saver which means you will be able to use the new battery saver api in L.


how to make ng-model value set by ui-select value

I am currently using angular-ui/ui-select in my project. I am able to bind the value of the ui-select to an object without issue, however it is binding the entire item that is being iterated over. I would like to only bind based on the item.codeId this would allow me to persist the correct data as well as display the correct value in the drop down when the page is loaded.

How can I setup ui-select to do this?

<ui-select ng-model="myObject.stateCode" id="stateCode">
    <ui-select-match placeholder="Select a state...">{{$select.selected.codeDescription}}</ui-select-match>
    <ui-select-choices repeat="item in constants.states | filter: $" value="{{$select.selected.codeId}}">
        <div ng-bind-html="item.codeDescription | highlight: $"></div>
        <small ng-bind-html="item.codeId | highlight: $"></small>


Your code is fine, but there was a bug that caused this when using a child array (constants.states).

I just fixed this issue at, specifically this commit

New version v0.5.1 released. If you’re using bower, just run bower update.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..