I'm having some trouble to make the file input work the way I want it. The file element exists of 2 parts, the textfield and the browse button. In other browsers than IE clicking either of them opens a window where you can select your files. In IE however it only opens when I click the browse button. If I click the textfield next to it I have to doubleclick in order for the window to open.
Is there a way to fix this with javascript so a single click on the textfield will also open the window? I tried the following, but it didn't work. (code is much simplified from the real example)
Html:
<input id="file" name="file" type="file"/>
JS / jQuery:
$("#file").click(function(){
$(this).trigger("dblclick");
});
$("#file").dblclick(function(){
alert("Double");
});
Now the above code alerts the "Double" but doesn't open the window. Is there a way to fix this?
Thanks in advance.
Since the entire control is native to the browser (and are never exposed as text box plus button) you simply do not have access to methods/events that will allow you to invoke the upload button. I believe this is mainly to avoid sites tricking the user into uploading non-intended files.
If you can manage to take a little time to implement a workaround, this does a nice of job of creating a rather nice upload component thats easier to manage. I'm sure a quick google will list you many other examples on how to style the file upload component.
Just tested your code with JSFiddle on IE6 (http://jsfiddle.net/SUWRK/) and, from my understanding, it works as you're expecting ... The alert shows up on a single click event (please note that's it's tricky to catch the dblclick event in IE < 9 - see https://gist.github.com/399624).
Are you sure there's not something else going on with the larger code set?
Related
I have created custom Issue Tab Panel with field, where I can add comment when Ill press my custom button “add comment”
In my VM template I have
AJS.$("#add-comment-button").click(function(e) {
e.preventDefault();
AJS.dialog2("#add-status-comment").show();
});
This button works fine and window to write text appears, but… In other section in Issues --> Current Search —> Views (Detail Views), windows with space to write text dont appear when I click button “add comment”. It only appers in normal view of issue… Whats problem?
I'm not sure if I understand your question right so I'll give it a try. Maybe it helps in one or the other way.
As you didn't provide the code affecting the window I assume it is possible you are retrieving the issue key or issue id. There are some Jira JS calls that don't work in every view. The reason is unknown to me, but maybe if you use different calls it will work.
Here is the question and answer to this field availability problem on the atlassian community: https://community.atlassian.com/t5/Jira-questions/Get-issueID-in-JavaScript-in-Project-Screen-viewing-issue/qaq-p/824175
Otherwise you should provide some more information.
Regards
Chris
I work on Angular4 and 5 and I have a functionality to upload a file in the table. So, on click of an Add button a pop-up will appear and through that pop-up we can browse or drag-drop a file/files.
My requirement is as soon as the drag-drop/browse is done I have to make a service call. So is there any way I can capture an event if the files has been browsed/drag-droppped? If so please guide me. IS there any other way I can achieve this?
PS: This upload pop-up and the Add button is 3rd party, I cannot make any change in their component/HTML. The thing I am trying to do is to capture the event, if there is any other way please suggest.
HTML
<button>Add Files</button>
<3rd-party-upload-popup></3rd-party-upload-popup>
Can you please make a plunker for the same, specifying where actually you need the event. Otherwise what i understood is that when you drop something, you may require an event. For this in Angular drop event is there. Also you may want to look at sortableJs
I have a question that is a little outside my realm. I'm a newbie to jquery and javascript. I run a forum on ProBoards, and when the forum runs out of its allocation for attachments (pictures the users can post) I have to manually go through the attachment list and check every single checkbox one by one, then I am able to click a delete button to delete every attachment I've checked. Checking the thousands of boxes one by one takes forever. There is no implemented "check all", and there are thousands of checkboxes.
In the code, every single checkbox has the name ids[]:
<input type="checkbox" value="1494" name="ids[]"></input>
So I should be able to target them by the name "ids[]" I would think. The value is different for each one. The name is the same for all. But the question is... what code would I use and where would I put it in Firebug or Inspector? I'm sadly too much of a noob to be able to figure out what I would do.
I have Firebug for Firefox, and in that I have the add-on jQuerify, so I can force jQuery into the code if that helps create the simplest solution.
Basically I'm looking for a way to add some code to automatically check every single one of these boxes (or add a button that will allow me to do so if that is the only way), and I must be able to do it from Firebug or the Inspector in Firefox (or even in Chrome would be fine). I don't think I am able to modify the code (permanently) of this specific administrative page of my forum, so I need to be able to do it from the Inspector/Firebug. I'd like something I can just copy and paste into there to save myself 45 minutes to an hour of clicking thousands of checkboxes one by one.
Any solutions?
Use like this,
$("input:checkbox").attr('checked','checked');
You should be able to use the following in the console:
$('[name="ids[]"]').prop('checked',true)
Using Inspector Console F12 you can get all checkbox and check them
$('input:checkbox').prop('checked', 'checked');
I have a LiveCycle form in Designer that has a flowable menu page with checkboxes. When a checkbox is checked, certain pages are 'shown' in the document. The pages are subforms containing an image.
This functionality works fine. What I want to do is add a button to the front page that will remove the front page, open a 'saveas' window and then close. I can get the saveas and the close function to work but the front page gets cleared and is left blank in the document. If there is nothing on the page then surely it should realise it is not required as per the workflow?
Any workarounds would be greatly appreciated, this has been doing my head in for weeks! I know I can't delete the page using the acrobat model as there aren't the correct permissions. I'm hoping a bit of javascript on the button will do the trick.
At the moment I have:
this.resolveNode ("indexSub").presence = "hidden"; //indexSub is the subform
app.execMenuItem("SaveAs");
app.execMenuItem("Close");
I will look at forcing a filename at save another time!
Thanks
It is quite strange behaviour. I've checked that you can set presence either to invisible or inactive and it works fine then.
this.resolveNode ("indexSub").presence = "invisible"; // or "inactive"
Differences between invisible and inactive you can fnd here: http://blogs.adobe.com/formfeed/2009/03/xfa_30_presenceinactive.html
Actually "inactive" did play a part in the solution, not entirely sure if it was intentional!
The main change was to alter the first page from flowable to positioned. When the button was pressed, the page cleared, the SaveAs dialogue opened and then the document closed. When the saved document was reopened the menu page had disappeared as required. I'll add a comment to this if anything changes. Thanks all.
So I have an input, something like this:
<input type="file" id="file" />
I want to get the file open dialog to popup via javascript. I have tried things like this:
$('file').click();
(that's assuming I'm using something like prototype/mootools/jquery). However, this doesn't seem to do anything. Is there anyway I can trigger the click event for the file input without the user being forced to interact with the input directly?
I recall this is not possible due to it being a security feature. In fact, I'm pretty sure the button for the file browsing dialog does not even show up in the DOM (the field shows up, but not the button, which the browser renders automatically)
$('file').click()
This works (in Chrome 8). You just need to make sure it's not set to display: none;
An easy solution is to position it absolute and then set left to something like -1000px.
IIRC browsers don't allow this as a precaution mechanism. A script shouldn't be able to automatically upload a file in some way and tinkering with the File Open-dialog would be one of those ways.
Obviously this is bad in some situations...
As far as I know opening the file open dialog from javascript is blocked for security reasons.