custom-data-attribute

How to select an element based on the property of an object inside a data attribute?

微笑、不失礼 提交于 2021-02-08 05:22:22
问题 If my markup looks like this: <div data-test="{ "value" : "bar", "_id" : 1234, "name" : "john", "age" : 25 }">...</div> <div data-test="{ "value" : "foo", "_id" : 1235, "name" : "paul", "age" : 26 }">...</div> <div data-test="{ "value" : "drummer", "_id" : 1236, "name" : "ringo", "age" : 22 }">...</div> How would I select a particular element using JQuery if I only had the key 'bar' or 'foo'? I could pull out the whole object for each row and iterate through it looking for a match but I'd

How to localize Range attribute?

北城余情 提交于 2021-02-07 19:43:39
问题 So I need to localize this [Range(1, 150, ErrorMessage = "")] I tried to use [Range(1, 150, ErrorMessage = MyApp.Properties.Resource.ErrorMessageMustBeBetween)] where MyApp.Properties.Resource.ErrorMessageMustBeBetween is "{0} must be between {1} and {2}." and it says An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type How it could be done then? Thank you! 回答1: You need to use ErrorMessageResourceType and

Removing all dynamic 'data attributes' of an Element [duplicate]

半腔热情 提交于 2021-02-07 13:20:29
问题 This question already has answers here : Remove multiple html5 data-attributes with jquery (7 answers) Closed 6 years ago . I have a div where dynamic data- attributes get added on some tags. (name of data- attributes to be generated dynamically by script, so there is no way my script will know the NAME of data-attribute) <div data-1223="some data" data-209329="some data" data-dog="some value"> </div> Now, I want to write a code in which it resets the div by removing all the data attributes

Removing all dynamic 'data attributes' of an Element [duplicate]

北城余情 提交于 2021-02-07 13:19:37
问题 This question already has answers here : Remove multiple html5 data-attributes with jquery (7 answers) Closed 6 years ago . I have a div where dynamic data- attributes get added on some tags. (name of data- attributes to be generated dynamically by script, so there is no way my script will know the NAME of data-attribute) <div data-1223="some data" data-209329="some data" data-dog="some value"> </div> Now, I want to write a code in which it resets the div by removing all the data attributes

jquery posting data attribute to the next page

北慕城南 提交于 2021-02-05 09:46:34
问题 I am trying to post data stored in a data-attr to the next page, here is my code First i add a class and data-attr to all anchor tags like this: jQuery("a").addClass("wptl_link"); jQuery('a').attr('data-wptl_ip', '<?php echo $_SERVER['REMOTE_ADDR']; ?>'); I have checked my source code when uploaded and this works fine. I would like to add functionality to each anchor tag, to submit the data-attr of that anchor to the next page. I am now not quite sure on what to do. I have read into .ajax and

React TypeScript get Data Attribute From Click Event

ぃ、小莉子 提交于 2020-12-08 06:15:41
问题 So I have a React component with a button which has a click handler which uses the data-* attribute. If this was straight React then I know how to get the value from the data-* attribute. However I am learning how to use TypeScript so I have no idea how to get access to this attribute. So what is the best way to get access to the data-* attribute using TypeScript? This is my JSX code for the button: <button type="button" className="NavLink" data-appMode={ AppMode.MAIN } onClick={ this

React TypeScript get Data Attribute From Click Event

泄露秘密 提交于 2020-12-08 06:15:36
问题 So I have a React component with a button which has a click handler which uses the data-* attribute. If this was straight React then I know how to get the value from the data-* attribute. However I am learning how to use TypeScript so I have no idea how to get access to this attribute. So what is the best way to get access to the data-* attribute using TypeScript? This is my JSX code for the button: <button type="button" className="NavLink" data-appMode={ AppMode.MAIN } onClick={ this

How to export or get LOCAL variables of a *ngFor loop OUTSIDE it in Angular (v9, Material)

流过昼夜 提交于 2020-04-17 22:53:52
问题 First steps in Angular (with Material at version 9). I'm creating a form with the following code: HTML: <mat-form-field> <mat-label>Course</mat-label> <mat-select [formControl]="subjectControl" [attr.data-tag-subjectSemester]="this.subjectControl.value ? this.subjectControl.value.trim() : '' [attr.data-tag-subjectName]="this.subjectControl.value ? this.subjectControl.value.trim() : '' (selectionChange)="onChange($event)" required > <mat-option>-- None --</mat-option> <mat-optgroup *ngFor="let