html input file action after file selected - html

I am in a predicament with input files. The project I am working on has added a jQuery extension that masks all input types and makes them more 'vibrant'. However it has also caused a lot of trouble in the updating of what is listed in these inputs. One such problem is the input with type file. It currently will not change what is being uploaded after the very first selection. So I am wondering if there is a command you can use to do something after the user has selected a file (pressed the Open) button.

I'm not exactly positive on what you're asking for but: you can bind logic to the input's onchange event. This will run the code attached to it after the user has selected their file(s) and pressed the "Open" or "Cancel" buttons.
Here's an example using jQuery (since you've already stated you're using it):
$("#yourFileInput").change( function() {
alert("Hey, you changed me!");
});

Related

Using VBA to click a button with no ID

I'm trying to use VBA to navigate to a website and then extract some data. So far I've been able to navigate to the website and, but I can't figure out how to click on the buttons I need. Based on the research I've done, using querySelector is a much better option than using getElements.
When I inspect the button I'm trying to click on it brings me to the following line in IE's DOM explorer
<INPUT width="80" class= "button" onclick= "updateSummary();" type= "button" value="Apply Filters"></input>
Based on my research, I've got the following:
.
.
.
Ie.document.queryselector("input[value=Apply Filters]") (0).click
But I get a
runtime '438' object doesn't support this property or method.
I'd also like to be able to click on an "Export to CSV" button, and the html code has an href component and a source = "dynamically changing code based on the day" component.
Would it be possible to click on the export to to CSV button and either open the file or save it in a folder?
Thanks so much for the help!
Two things:
As mentioned in comments, drop the zero as you are not dealing with a nodeList. querySelector returns a single node which is the first match for the specified selector, or null.
You cannot pass a selector for attribute value that contains spaces without enclosing within ''
ie.document.querySelector("[value='Apply Filters']")
You could also use:
ie.document.querySelector("[onclick='updateSummary();']")

How to check html form if its re-dirtied?

(using angularJs 1.6)
I have a form that has some controls, and a save button.
When I click save, i check to see if the form is dirty.
If its dirty, then i save the changes off to a database, then set the form.dirty to false.
I also have if form is dirty, and user tries to navigate away without saving, there is a warning message that the form has not been saved.
If i navigate away after saving and come back everything works as expected.
But if I change something, then save. Then change something else. The form does not go dirty without refreshing first.
Without seeing any code, I can only answer based on what you mentioned and therefore you shouldn't be changing the form's $dirty property manually.
You should use the $setPristine(); method instead.
As mentioned in AngularJS Docs:
Setting a form back to a pristine state is often useful when we want to 'reuse' a form after saving or resetting it.
Which sounds like what you are attempting to do.

PhpStorm combine multiple Predefined Live Template functions

I have a project where my files are in "lisp-case" (hyphen delimited) and I would like to use the filename as a variable in a live template, but it must be converted to CamelCase first.
I found out that you can set the expression fileNameWithoutExtension() under "Edit Template Variables" and there is also a function called camelCase() which should be able to turn my filenames into CamelCase. But I cannot figure out how to combine those two. I tried doing camelCase(fileNameWithoutExtension()) but that does not work, unfortunately.
Is it possible to achieve this some other way?
camelCase(fileNameWithoutExtension())
It's a correct syntax.
Is it possible to achieve this some other way?
Please ensure that Skip if defined checkbox is checked for this variable.
If I try to wrap fileNameWithoutExtension() inside camelCase() and press enter to save the entry the window is closed but the change is not saved
It's an IDE bug (https://youtrack.jetbrains.com/issue/IDEA-132965 -- supposed to be fixed in current 2017.1.x version).
In any case: either press Enter before leaving the field ... or click on OK button straight away (you may then reopen this window to do further changes).
Also, when editing the field it's rendered like a select box which is kind of weird. Maybe it's a bug in this specific version. I'm on PhpStorm 10.0.4 for Mac.
Not a Mac user here .. but it is an editable drop-down box indeed (it lists all possible functions).

passing a variable inside a variable to an angular directive in html

I am doing a signup form with a few steps, made with angular material tabs. I have 5 tabs each containing a few inputs that the user should fill in. I also have 2 buttons below the tabs, one to get to the next tab and one button to get to the previous tab. I want to disable the upcoming tabs and also disable the button that takes the user to the next tab until the user has filled in the the tab he is on properly. I want the user to be able to go back and change the information that is already filled in on the previous tabs, and when all the tabs are filled in properly a send button is shown. So, that's basic functions for a multi step signup form.
I have managed to do the basic functions for the buttons and the tabs with ng-disabled and ng-hide combined with changing the value on the variable tabNr in my controller, like hiding the previous-button on the first tab and hiding the next-button on the last tab, and that works fine.
When it comes to hide the next-button based on if the form is filled in its a bit more tricky. I am able to disable the next tab by validating the form on the previous tab like this: ng-disabled="!tab1Form.$valid", so that's hard coded and works fine.
The previous- and next-buttons, though, are the same for all tabs and that is the tricky part, so I can't just disable the button if a form isn't valid because the button does not know which tab that is active. I have tried to make a function in the controller but then the problem is that the valid-variable is just a thing in html and I cant evaluate it in the controller.. As far as I have tried and have understood.
So this is the next-button:
<md-button ng-click="FormCtrl.tabNext()" ng-disabled="FormCtrl.tabNr >= 5 || !tab{{FormCtrl.tabNr}}Form.$valid" ng-hide="FormCtrl.tabNr > 4">Next</md-button>
Each tab has this, with it's own number:
<form name="tab1Form" novalidate>
What I've tried is to change the tab, that should trigger the disable, by using angular:
ng-disabled="!tab{{FormCtrl.tabNr}}Form.$valid"
The browser seems to change the number, and it works for the first tab, but on the rest of the tabs it does not disable the button even though it should, like if the browser does not evaluate the variable properly. I hoped that it should work because I cant think of another way of doing it with these variables...
Does this way of using angular simply not work or am I doing anything wrong? Does anyone have a solution I could use?
In your controller
function Controller($scope){
var vm = this;
vm.form = $scope['tab' + anyNumber + 'Form'];
}
then in your html
ng-disabled="!FormCtrl.form.$valid"

Angularjs, intellisense for setting value of directive in html5 (webstorm)

Just want to ask a simple question since I am new to angularjs and html5.
I have written a directive to check if user has permission for a certain thing. Permissions are all an array of strings. Using directive I am hiding or showing a UI element if user has permission for that. For example if user doesn't have permission for editing a user, I would hide the edit button with the help of directive as follows;
div that contains edit button
<div has-restriction="UserEditNotAllowed"><button>Edit User</button></div>
My question is instead of typing in string "UserEditNotAllowed", is there a way so that while typing it, using intellisence I can see permission strings that are available to avoid typos.
I tried adding these permission string in $rootScope but intellisense doesn't show that. I am using webstorm.
Thanks,
Imad.
Firstly you don't have to use your own directive for hiding stuff based on app logic. Instead you could use ng-show.
<div ng-show="userAllowed"><button>Edit user</button></div>
Then inside your controller, set $scope.userAllowed = true; whenever you want the button to become visible.
As for intellisense, that is an entire other question which should be aimed at webstorm.