*<af:commandButton text="#{res['pci.buttons.save']}"
blocking="true"
disabled="#{claimFileDetailAddBean.buttonsDisabled "}
action="#{claimFileDetailAddBean.save}"/>*
I use this html. I want; button block proceed until the end of action. How is this possible.
So you want to dynamically disable / enable your button?
In that case you can use javascript DOM
You can use the tag object.disabled=true to disable and object.disabled=true to disable.
All you have to do is making a function for it.
BTW: next time be more specific in your questions.
Related
I want to track clicks on the following button/link with Google Tag Manager. I created a trigger in Google Tag Manager that triggers when the element_id = 100. This works fine, except that when I click exactly on the text, it doesn't do anything, the link looks like a button, with the text in the middle of it. I can't change anything to the html or css, otherwise I can think of multiple things, so I need to find a solution without changing the html. Also, the 'myclass' class and the 'label' class get used in other elements.
<a class="myclass" id="100" href="http://www.url.com">
<span class="label">Text</span>
</a>
Anyone an idea?
Thanks a lot,
The following workaround worked:
Create trigger when element text contains "Text". This will trigger events on the button and the label on the button, of all buttons with "Text" as label.
Create tag for that trigger that checks with simple javascript if either the id of the current element = 100, which will happen when you click the button but not the label, or that the id of the parent = 100, which happens when you click the label. You can get the element that triggered the tag using the built-in variable "Click Element". Which you need to access the parent element.
Technically, you shouldn't have a CSS ID that starts with (or is) a number, so not sure if your code example is accurate or not. Whatever the case, you're probably better off using "matches CSS selector" so that you don't need to use any custom JS.
If indeed your HTML uses id="100", then the above will work. If it's anything else that doesn't start with a number, then you can use
#whatever > span
I have a span with an ng-click="..." attribute. The ng-click slightly modifies the span's CSS within the DOM so that it is more button-like. Within my application I wish to toggle whether or not that span is clickable or not. I can make the ng-click not do anything easy enough but what I would prefer is to just remove/disable the attribute altogether. This is to avoid all "buttonizing" that the ng-click does to the element. It would also be nice if the attribute were re-enabled if the clickable variable becomes true again.
I would like a solution that avoids using $scope.$watches because my application is pretty large and watches are slow.
Thanks!
I think you can have two spans with and without ng-click attribute and based on that clickable variable you control those two spans with ng-if or ng-show
Simple solution suggested by to Achu!
Just use two spans rather than toggle the attribute on a single span.
<span ng-if="clickable" ng-click="...">Click me!</span>
<span ng-if="!clickable">Cant click me!</span>
If I were in such a situation, I would not try to enable or disable ng-click attribute. Rather, I would use some flag variable with the $scope to see if click function should perform its functionality or not like in your controller you have a method like
$scope.spanClick = function(){
if(!$scope.shouldClick){
return;//simply do nothing
}
//Do button click logic
}
Trying to add the submit button dynamically through javascript, below is the code snippet, not sure which attribute to use for setting the text.
var dynSubmit = document.createElement("paper-button");
dynSubmit.setAttribute("on-click", "submitForm");
//dynSubmit.setAttribute("Value", "Submit");
parent.$.iron-form.appendChild(dynSubmit);
The commented code does not work, How do i set the caption of submit button?
You can set the button's innerHTML.
Polymer.dom(dynSubmit).innerHTML = "Submit";
Thanks to #jonsS0 for his handy comment.
Avoid using innerHTML with Polymer, or at all really; it's slow, it's where XSS can get in, and you shouldn't need it.
Instead use textContent:
dynSubmit.textContent = 'Submit';
You can set this without breaking the ripple and you shouldn't need the Polymer.dom(dynSubmit) as it's an exposed property on the underlying element.
This is a very rudimentary question, but I am sure someone out there knows why. In HTML, when I make a button element by itself, and do not give it and onclick and no jQuery .click() the button will just do nothing. Perfect. But when I do this and but the button inside a <form> element, it tries to send GET data of all the form elements to the root address of my website? Why is it doing that? I didn't make it a submit button or even define a method or action on that form??
Thanks for the info in advance!
** EDIT **
This is what I did to fix the problem. For buttons inside the <form>, use:
<button type="button"></button>
And it will not do anything by default.
As can be seen at the respective MDN entry, the default value for the type property of a button element is submit. So if you omit it or don't change it to button or reset, the default behaviour will kick in and the form gets submitted.
<form action="">
<button type="button">Nothing will happen</button>
<button>Form gets submitted</button>
</form>
I didn't make it a submit button
<button> elements have a type attribute. The default value is submit. Set type="button" if you don't want it to submit a form.
or even define a method
method defaults to GET
or location on that form??
action defaults to the current URI.
It was designed that way because you sometimes need to know WHICH button was pressed on the server-side. If you want button functionality without a button, use a styled A-tag.
Buttons are treated as submit controls in forms, not sure why.
The reason it gets posted to your root is because you didn't specify an action and so the default is used.
The reason it used GET is because that's the default method.
To prevent it happening, add return false; to the end of your button's onclick.
How can I remove the upload button helper FileUpload.GetHtml?
#FileUpload.GetHtml(
initialNumberOfFiles:1,
allowMoreFilesToBeAdded:true,
includeFormTag:true,
addText:"Adicionar",
uploadText:"")
Unfortunately not. The only way to remove it using code is to set includeFormTag to false. But then you'd lose all the rest of the post html. :)
However, since the html output is consistent you can just do a simple replace.
#Html.Raw(FileUpload.GetHtml(
initialNumberOfFiles:1,
allowMoreFilesToBeAdded:true,
includeFormTag:true,
addText:"Adicionar",
uploadText:"").ToString().Replace("<input value=\"\" type=\"submit\"/>", ""))
It's rather ugly though.