I have a SP.UI.ModalDialog. On the dialog there are two radio buttons:
Agree
Disagree
Then there is a submit button. The submit button checks to see what the value of the radio button is.
OnClick="if(document.getElementById('Agree').checked){var results ={result:'agree'};return SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK,results);}else{var results ={result:'disagree'};return SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel,results)}">
Now I want to add a "Close dialog" button, that simply closes the dialog. I don't want it to return any results. How can I simply close the dialog?
The following is not working for me:
OnClick="window.frameElement.SP.UI.ModalDialog.commonModalDialogClose();"
For anyone referencing this question in the future, apparently the problem is internet explorer in my dev environment. Not sure if it's so much a browser issue as it is a dev environment issue, though. The same code works in QA with the same version of ie. Will have to investigate my browser settings further in my dev envrmnt.
For what it is worth, I was also struggling with using a button to close a modal window. Passing null worked for me.
var _html = document.createElement();
_html.innerHTML = 'Something written in here <input type="button" value="Close" onClick="SP.UI.ModalDialog.commonModalDialogClose(1, null)">'
Related
I've been poking around the internet at large cobbling together some VBA code to try to interact with some web pages (and eventually scrape).
I have some decent knowledge of VB and programming, but the internet end of things is pretty new to me, especially the syntax of commands, so I'm leveraging things from the internet.
I have one that's working,
http://snowload.atcouncil.org/
This I can fill in and get to submit with a
doc.getelementsbyId("coordinate_address").value = range("City").value _
& ", " & range("State").value
doc.getelementsbyId("btn-submit").click
then wait it out until readystate =4 , etc.
The one I can't get to work is here.
http://windspeed.atcouncil.org/
This one seems to use a object that I can't figure out how to click. It doesn't seem to have a name, and Id, etc.
If I use conventional 'submit' on the windspeed page, (loosely using that term), the page loads, but it comes out blank. Like I'm not using the syntax correctly, or not passing a variable/searchform somehow.
ie.document.all.item("submit").click
This 'works' but it produces a blank page with the east coast of africa and no data.
In the immediate/console of the browser, after I click, say, the Hawaii button, it works with document.searchform.submit()
If I try that in code, it doesn't work. (The Immediate window in the VBA editor thows me a "expected: =" error,
The object I am trying to click is in the web site code.....
<span>
<input type="submit" value="Get Windspeed" onclick="valbutton(searchform); return false;">
<span>
I've tried a lot of techniques poached from the internet, but no success yet. (looping over elements using getelementsbyclassname "span", but it either doesn't find the one with value ="Get Windspeed", or it doesn't find it at all.
somehow triggering the valbutton (that's a subroutine/function on the page) seems like a workaround... but VBA seems to want different syntax than the console on the web page and it's doing the same kind of "expected: =" syntax error when I try that approach.
I suspect normal submit would work, but I'm somehow not passing the filled out page and am sending a blank to the submit/get?
I also notice that if you are on the page, type in an address, and hit enter, it runs that "find" button I can't figure out (same thing, no name or ID obvious, it's a button....), and if you hit enter after it reloads, then it somehow by default hits that 'get windspeed' button, which suggests to me they are both submit buttons in a way.
Thanks for reading, I appreciate any thoughts on the matter. I am trying to get this to get all the data input and get the results without adding anything beyond VBA (i.e. jscript or vbscript or other things,)
-Brian
You should be able to simply submit the form after setting the .Value of the inputs.
doc.getelementsbyId("searchform").submit
I was able to adapt this (despite the claim this doesn't work in IE11..., maybe I'm not using 11...Is eleven Miscrosoft Edge?)
https://www.mrexcel.com/forum/excel-questions/344297-need-visual-basic-applications-code-execute-javascript.html
IE.Document.parentWindow.execScript "CheckAndSubmit(document.frmViewMyAcct);"
that allowed me to mimic hitting the button or hitting submit and somehow got around the 'no information / resulting page is blank' issue. The onclick event has a javascript routine attached to it, so I just copied that syntax.
Thanks for the help, it got me started on the solution.
Regards,
Brian
By clicking a commandLink, I call an event on actionListener and after that, my dataGrid updates via AJAX then, onComplete, I call a javascript. It works fine on the first time but when I click the commandLink again, it does nothing.
Here's my code:
<p:commandLink id="addCompBtn" value="Add Computer" actionListener="#{coltsysLab.addComputer}" update=":organizeForm:availableComputers :organizeForm:labStat" oncomplete="getPos();"/>
My Javascript just positions each computer in a specific fixed location.
I am not sure what getPos() does; however, let's assume that it does not release event binding to the input DOM.
Try updating the commandLink as well:
<p:commandLink id="addCompBtn" value="Add Computer" actionListener="#{coltsysLab.addComputer}" update="#this,availableComputers,labStat" oncomplete="getPos();"/>
You should try removing oncomplete="getPos();" from your button and test again. If the button works fine beyond the 1st time then the problem must come from your JavaScript function. If that's the case, you should use the Developer Tools on any browser to investigate the issue. For example, on Chrome browser, right-click anywhere on the page then click Inspect Element, the Console section might help.
I've been trying to use a f:setPropertyActionListener on a Bootstrap modal launch button but it doesn't work at all. Tags a and button don't support it so I don't know what to do now.
I need to set an id of an item in a bean I have when I push the modal launch button, so I can then confirm delete that item using the modal.
I've searched here and on other sites and I've found a lot of solutions to my specific problem using Javascript but I have no idea about that :/
Thanks in advance.
I've been using Watir to automate testing of my companies primary web app. The tests require a javascript dropdown menu fired by mouse over, and a link on that menu to be clicked.
$browser.link(:id=> 'element').fire_event "onemouseover"
Was working perfectly until we changed the look and feel of the app. The changes made to the look in feel didn't appear to change in any way how the HTML looks and the menus work. Everything else is working fine with Watir.
I've tried using a solution that seemed to work for others, by including:
class Watir::Element
def hover
assert_exists
driver.action.move_to(#element).perform
end
end
and using
browser.div(:id => "someId").hover
But when the menus appear they instantly go away before the driver has a chance to click the menu item.
browser.div(:id => "someId").hover
sleep 3
Will solve the problem. I have faced same issue and sleep solved it :)
I've managed to get around this one (provided the site uses jquery) by using execute_script to fire off some jquery to override the visibility on the 'hidden' menus. See this answer https://stackoverflow.com/a/8392467/409820 for more info
Needing to do that was one reason I and others requested the .hover method, so that is also something you could try.
(my scripts are still using that particular trick because a) it's working, and b) I'm working on other stuff right now and don't have a pressing need to fiddle with them.
I am trying to use Jquery Mobile's dialog. On the documetnation, it says that diaglog would be closed if a user clicks any links on a dialog page.
Documentation:
"When any link is clicked within in a dialog, the framework will automatically close the dialog and transition to the requested page, just as if the dialog were a normal page. To create a "cancel" button in a dialog, just link to the page that triggered the dialog to open. This pattern of linking to the previous page is also usable in non-JS devices as well."
How do I prevent it?
Don't use an <a> tag, use a <div>
<div id="my_button" data-role="button" data-theme="a">Don't Close</div>
Then you just have to programmatically attach some actions to the clicking of that div
$('#my_button').live('click', function({
// do something
}
If you add a function to onclick, that will override the default behavior. Just leave href="#" in the tag, put the function like onclick="myFunction()" and you should be good.
Then in the function you can do the close with this: $('.ui-dialog').dialog('close')
Or you can obviously navigate to another page with: $.mobile.changePage('#page')
I'm sure you've moved on by now, but hopefully this can help someone else looking for this solution.
wom's solution is good, but you don't need to change from tag to . You just need to change href like href="#" as Mar said. I have test like this, it works fine.
And if still can't prevent default action, add e.preventDefault() on button's click handler.