acess the type of input in dojo - dojo

i enter dojo.query('input') i get the following :-
<input id="paragraphtwo" data-dojo-type="dijit/form/SimpleTextarea" rows="4" cols="50" style="width:auto">
now WHEN i write
text= dojo.query('input')
[<input id="paragraphtwo" data-dojo-type="dijit/form/SimpleTextarea" rows="4" cols="50" style="width:auto">]
gets storeed in text.
now when i write text[0].id i get "paragraphtwo". how can i access the type of input i.e hwo can i get "dijit/form/SimpleTextarea" just like i got the id

One way to this is as follows:
var input = dojo.byId("paragraphtwo");
var dojoType = dojo.attr(input, "data-dojo-type"));​
console.log(dojoType); // Outputs: dijit/form/SimpleTextarea

Using the declaredClass property:
console.log(dijit.byId("paragraphtwo").declaredClass);

Related

Having trouble with findAll statements

Trying to dig into html to get color.
color = soup.find_all('a', {'class' : 'logsss_event_cl itemAttr current'})
print(color)
What I get is:
[<a class="logsss_event_cl itemAttr current" data-logsss-const-value="{'x': 'change_color'}" data-value="WHITE" href="javascript:void(0)" title="**WHITE**"><img src="https://gloimg.rglcdn.com/rosegal/pdm-product-pic/Clothing/2019/04/24thumb-img/1556072536277922126.jpg"/></a>, <a class="logsss_event_cl itemAttr current" data-logsss-const-value="{'x': 'change_size'}" data-value="3X" href="javascript:void(0)" title="3X">3X</a>] href
What I want is "white"
Your search is returning all values for links with the class logsss_event_cl itemAttr current. If you want the text value, you can accomplish that using the following code:
# first, get all values for colo
color_all = soup.find_all('a', {'class' : 'logsss_event_cl itemAttr current'})
# Next, only get text
color_text = [x.get('title') for x in color_all]

selenium ide extract text from input tag [value attribute]

I am using selenium IDE for writing test case and I am trying to extract content in value attribute of below tag
<div id="inputcontainer_f-5" class="FGIC" style="max-width:none;"><input type="text" autocomplete="off" name="f-5" id="f-5" class="dummyclass FastEvtFieldFocus" value="TEXT_I_WANT_TO_GET" readonly="readonly" spellcheck="true" tabindex="-1" style="">
</div>
My selenium IDE code
comment | Target | value
store text | xpath=//input[#id='f-3'] | EXTRATCED_CONTENT
echo | ${EXTRATCED_CONTENT}
Result : I am getting empty string
echo : ""
If i try to change the xpath as xpath=//input[#id='f-3']/#value I am getting following error
storeText on xpath=//input[#id='f-5']/#value with value EXTRATCED_CONTENT Failed:
The result of the xpath expression "//input[#id='f-5']/#value" is: [object Attr]. It should be an element.
How do i extract and store TEXT_I_WANT_TO_GET in variable EXTRATCED_CONTENT and echo it
Thanks
Jk
Try this below.
//input[#id='f-3']#value

Default value pre-selected in select box with ng-options

I am trying to get default value selected (from database) in my select box using ng-options.
My view
<select class="form-control samlength modalinput"
ng-options="p.procid as p.procname for p in processes track by p.procid"
ng-model="p.procid">
<option value="">-- choose an option --</option>
</select>
where p.procid is a value received from the database.
My data
procid procname time
1 MyProcess 2018-05-30 13:34:54.097 3003162
3 Testing 2018-05-31 18:31:32.467 3003162
If selected procid is 3, how can I get it to be selected by default?
FYI - I have tried multiple answers given in other threads. I have also tried ng-init but nothing helped.
You can keep your HTML as:
<select class="form-control samlength modalinput"
ng-options="p.procid as p.procname for p in processes track by p.procid"
ng-model="selectedProcess">
<option value="">-- choose an option --</option>
</select>
Now if we have a requirement to select a particular object in the array. We can do that by iterating through the array and comparing value at the given key:
function functiontofindIndexByKeyValue(arraytosearch, key, valuetosearch) {
for (var i = 0; i < arraytosearch.length; i++) {
if (arraytosearch[i][key] == valuetosearch) {
return i;
}
}
return null;
}
Call this function as:
var index = functiontofindIndexByKeyValue($scope.processes, "procid", procid);
$scope.selectedProcess = $scope.processes[index];
alert(index);
Hope it works!
Update your html code to this:
<select ng-model="processSelected"
ng-options="p.procname for p in processes track by p.procid">
</select>
Then in controller initialise your model value as:
$scope.processSelected = $scope.processes[1];
Where $scope.processes is an array of process objects.
Plunker Example

Trying to connect a HTML5 date input with date model

I have an HTML5 date input element like this:
<input type="date" />
if you choose a date in this input a string will be the value, for example:
"2018-12-31"
In my model I want the date to be presented as the following string:
"2018-12-31T00:00:00.000Z" and not the simplified string.
How do I make sure that the date in my model keeps the correct format? I tried using a computed but since I am in a loop this time I cannot use them.
{{eventDate.date}}
<b-form-input
v-bind:value="eventDate.date"
v-on:input="eventDate.date = $event.target.value"
v-bind:id="'event-day-date-' + index"
size="sm"
type="date"
placeholder="2018-12-31"
>
</b-form-input>
As you can see here the eventDate.date is a long string but the input needs the format YYYY-MM-DD. I need to convert it to and from this format some way.
You could use a filter:
filter: {
dateToString(date) {
return date.toString().substr(0,10)
}
}
and then update your template
:value="eventDate.date | dateToString"
This is what I ended up using:
<input
v-validate="'required'"
v-bind:name="'eventdate-' + index"
v-bind:value="eventDate.date | dateToString"
v-on:input="eventDate.date = $event.target.value + 'T00:00:00.000Z'"
v-bind:id="'event-day-date-' + index"
class="form-control form-control-sm"
type="date"
placeholder="2018-12-31"
/>

How do I conditionally add an id attribute in TAL (PHPTAL)?

I'm creating a form elements template file in PHPTAL. I would like to be able to OPTIONALLY pass in an id attribute for a field...
So far the code looks like this:
<xml>
<tal:block metal:define-macro="text">
<label tal:condition="php: !isset(hideLabel) || isset(hideLabel) && !hideLabel">${field/label}</label>
<input name="${name}" type="text" value="${field/value}" />
<p tal:condition="exists:field/error">${field/error}</p>
</tal:block>
</xml>
This works as advertised. What I'd like to add is something, like
<input name="${name}" tal:attributes="id exists: id $id | $name" value="${field/value}" />
to allow me to optionally pass in an id from the METAL call...
Should I be doing it differently? I've tried using PHP: isset(id) ? $id : NULL and variations thereof, but just end up with an id="0" in the resultant HTML.
Any ideas?
In case anyone else needs it, one working answer is:
<xml>
<tal:block metal:define-macro="text">
<label tal:condition="not: exists:hideLabel">${field/label}</label>
<input name="${name}" tal:attributes="id id | nothing" type="text" value="${field/value}" />
<p tal:condition="exists:field/error">${field/error}</p>
</tal:block>
</xml>
Where passed in variables are id, name, an array named field, and hideLabel .
Note, that I've also managed to simplify the label test to something which I believe is more idiomatically TAL.
Set VAR at a DIV containing the soon to be used element:
div class="" tal:define="VAR context.property"
div class="" tal:attributes="class python:'grid_8 omega' if VAR else 'grid_8 alpha'"
in PHP:
<div id="contentCenter" tal:attributes="id
php:isset(variable)&&isset(variable.property)?'IDVALUE':NULL">