In JQuery, how to filter by both "button" and "not in class"? - jquery-selectors

In jQuery selector, I know hot select all Button:
$("input:button")
And how to not contain class
$("input:not(.class1)")
But how do you filter by both?

$("input:button:not(.class1)")
FWIW, consider using <button> and not <input type="button"> when it makes sense to do so...e.g., if your button input doesn't have a value, why would it be an input element?
Cheers

You can use .filter()
$("input[type='button']").filter(':not(.class1)')

Related

Simplest way to submit form through Enter key pressed from any form field?

To submit a form by pressing Enter key the standard solution is:
<input v-model="name" v-on:keyup.enter="submit" />
But what if a form has many input fields? Is it necessary to add v-on:keyup.enter="submit" to every single one of them, or is there a simpler solution?
In this case, you should wrap the inputs in a form as follows:
<form v-on:submit="submit">
</form>

xpath - how to select this submit button?

How can I select this submit button?
<li id="district_schedule_set_submit_action" class="action input_action ">
<input class="sexybutton sexysimple sexyorange" type="submit" value="Generate Schedules" name="commit"></input>
</li>
What didn't work...
//input[value()='Generate Schedules'
//form[input()='Generate Schedules']
//input(text(),'Generate Schedules'))
//input[text(),'Generate Schedules')]
I believe
//input[#value="Generate Schedules"]
will work
Another option: //input[#type='submit']
//input[#value='Generate Schedules']
will work (not sure it likes double quotes). When you want to match the exact text, you use the = sign. If you are trying to match partial text, you use a comma wrapped in contains:
//input[contains(#value,'Generate')]
This code can be used to check in console in developer tools in Chrome
$x('//button[#label="Submit"]')

How do I replace an attribute value for attribute with multiple values in Wicket?

My class attribute has two CSS class values. The HTML starts out like this:
<input type="button" wicket:id="rowButton" class="jelly-button greenGradient"/>
And I want to dynamically change it to this:
<input type="button" wicket:id="rowButton" class="jelly-button redGradient"/>
Currently I am doing this:
component.add(new SimpleAttributeModifier("class", "jelly-button redGradient"));
What is the best way to do this in Wicket? There must be a more 'proper' way to do this than what I have done above.
Instead of using an attribute modifier with fixed text you could use an attribute appender with the text retrieved from a model. To change the class, just change the model's value. For example:
Model<String> gradientModel = new Model<String>("greenGradient");
...
component.add(AttributeModifier.append("class", gradientModel));
in the markup just have
<input type="button" wicket:id="rowButton" class="jelly-button"/>
Then when it is time to change the gradient use
gradientModel.setObject("redGradient");
or
gradientModel.setObject("greenGradient");
The example in the javadoc below explains it well
http://www.jarvana.com/jarvana/view/org/apache/wicket/wicket-core/1.5.2/wicket-core-1.5.2-javadoc.jar!/org/apache/wicket/behavior/AttributeAppender.html

can't select the YES option

How do i make Watir select a specific radio button? I have 4 radio buttons, and i want it to select the second one:
//this will select the first option
ie.radio(:name, "radio1").set()
I can even set the second option for another radio button doing the following (for a different radio button):
ie.radio(:value => '1').set
however, i have the following radio button:
<input type=radio name='myRadio' id='myRadio-0' value='0' tabindex=8 ><span class=smalll>0. No</span>
<input type=radio name='myRadio' id='myRadio-1' value='1' tabindex=8 ><span
class=smalll>1. Yes</span>
I want to select the the "YES" option here, but no matter what i try, i can't. How do i get around this? I've tried the following:
ie.radio(:value => '1').set
ie.radio(:name, "myRadio-1").set
ie.radio(:name, "myRadio").set
any ideas?
In your example you've used name twice, even though "myRadio-1" is the id of the element, not the name. If that was a typo just in this post and not in your actual code, I would assume that one of the two radio buttons not provided (of the four total) has a conflicting name/id, etc.
For HTML:
<input type=radio name='myRadio' id='myRadio-1' value='1' tabindex=8 >
I would use:
#browser.radio(:id => "myRadio-1").set
Typically radio buttons are in a group. In the examples I've seen, people set the one radio out of the group rather than focus on a radio button.

Using negative value in Zend Form Element Radio causing html errors

$score = new Zend_Form_Element_Radio('score');
$score->setRequired(true)
->setSeparator('')
->setMultiOptions(array(1 =>'Positive', -1 =>'Negative'))
->setDecorators(array('ViewHelper'));
Renders as
<label for="score-1">
<input name="score" id="score-1" value="1" checked="checked" type="radio">Positive
</label>
<label for="score-1">
<input name="score" id="score-1" value="-1" type="radio">Negative
</label>
Is the fact that it's using the same ID for the inputs and labels normal behavior or a bug?
How can I correct this?
I can't change the values as technically they are required to be that way
The real problem this causes is that when you click the negative the positive gets selected instead!
Thanks
Looks like the standard ViewHelper decorator for a radio control uses a FormRadio view-helper. When this view helper creates the id it uses on the <input> element and the <label> element, it first applies the standard AlNum filter, which is filtering out your minus sign.
So, it looks to me that instead of using the standard ViewRenderer decorator, you will have to create a custom decorator that calls your own custom FormRadio view helper.
You might be able to avoid creating your own decorators and view helpers by creating your own custom AlNum filter that allows those minus signs. The trick is to set that path only for this single use so that you;ll be able to use the normal Alnum filter for other elements.
Alternatively, you could probably trick the ViewHelper into using a custom FormRadio helper by adding a helper path on the view object so that it loads your custom view helper instead of the standard one.
Just some ideas.