custom-data-attribute

Escape/Special Characters from user input to HTML5 data-attributes using URL Encode/Decode

 ̄綄美尐妖づ 提交于 2019-12-07 15:53:59
问题 This is my first question on stackoverflow - needing help from all you experts. Our web app allows the user to input escape/special characters. We are doing some testing for extreme cases. I'm able to pass the escape characters through ajax/json. var test = JSON.stringify({ typeName: $("#typeName").val(), invoiceType: 'NewTypeArea' }); $.ajax({ type: "POST", url: "BackEnd/WebService.php", data: { newInvoice: test }, dataType: 'json' }); <script src="https://ajax.googleapis.com/ajax/libs

using html data-attributes as css-variable (i.e. text-shadow)

吃可爱长大的小学妹 提交于 2019-12-07 06:57:57
问题 i'm trying to use inline data-attributes as variables for css... is there any known option to get this run: .mycss-class {text-shadow: attr(data-textshadow); } <div class="mycss-class" data-textshadow="0 0 0 #000">lorem ipsum</div> chrome dev-tool just reports "invalid property value" many thanks & kind regards 回答1: You can do this with CSS Custom Properties. Support is pretty good, including Edge (but no IE) p { width:80%; margin:1em auto; text-shadow: 2px 6px 2px grey; } p.colored { color:

jquery .data not visible in firebug?

丶灬走出姿态 提交于 2019-12-06 20:29:23
问题 I can use the jquery .data attribute and an alert confirms that it worked, but I don't see data attribute in page using firebug. $('#something').data('foo', 52); alert($('#something').data('foo')); 回答1: The information put into .data(...) is not a visible DOM attribute. You can view an object's data by doing console.log($('#something').data()); Demo: http://jsfiddle.net/maniator/pQybU/ 回答2: jQuery doesn't actually add a data attribute as such to the element and so there is nothing in the DOM

jQuery simple checkbox to hide and show divs (product filtering)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 03:49:57
I am using jQuery to filter product items on a page (hide and display DIVs) I am using filter as a replacement since PHP $_GET is a bit old fashion we're trying to do this via jQuery. I using filter() and data attribute. How can I turn off the current selection of checkboxes except the existing item? How can I hide the items based off selection and unhide when not? HTML <input type="checkbox" id="drama" onClick="filterCategory(this.value)" value="drama" /> Drama<br /> <input type="checkbox" id="romance" onClick="filterCategory(this.value)" value="" /> Romance<br /> <input type="checkbox" id=

Access object value from parameter attribute in C#

懵懂的女人 提交于 2019-12-06 03:47:31
问题 This is my method public Component SaveComponent([ValidateMetaFields] Component componentToSave) { ... } This is my custom attribute: [AttributeUsage(AttributeTargets.Parameter)] public class ValidateMetaFieldsAttribute : Attribute { public ValidateMetaFieldsAttribute() { // how to access `componentToSave` here? } } I am wondering is there a way to access componentToSave object from ValidateMetaFieldsAttribute ? I could not find any sample code or examples. 回答1: No, attribute instances don't

Prevent converting string containing an E and numbers to number

会有一股神秘感。 提交于 2019-12-06 03:00:07
问题 We have this 'strange' situation where some product codes, for example 11E6, which are stored in data attributes (ex data-prodcode) are getting converted to 11000000, when retrieved inside jquery click function. Something like this: <a data-prodcode="11E6">click</a> var code = $(this).data('prodcode'); console.log(code); --> 11000000 Any advice on how to avoid this behavior or what may cause it? 回答1: From the documentation : Every attempt is made to convert the string to a JavaScript value

jQuery 1.4.4: How to find an element based on its data-attribute value?

情到浓时终转凉″ 提交于 2019-12-06 00:59:28
问题 I imagine this should be a pretty trivial task but using Firefox for Mac, 3.6.12 the following does not work: // assign data attributes $('.gallery li').each(function(i) { $(this).data('slide',i+1); }); // outputting an empty jQuery object console.log($('.gallery li[data-slide]')); // this does not work either outputting an empty jQuery object console.log($("[data-slide]")); using Firebug I can see that all the data-slide attributes including their numerical value are correctly attached to

Using jQuery to select elements with data attributes assigns a null ID to its parent elements

假如想象 提交于 2019-12-05 21:35:45
This is truly bizarre. If I use jQuery's .find() to find child elements that have data attributes during a scroll event, then scrolling the page will repeatedly add and remove an ID to the parents of those elements. It's difficult to describe, but here's a reproducible test case: http://jsfiddle.net/8fouvx9p/ var groups = $(".group"); $(window).bind("scroll resize orientationchange", function() { showGroup(); }); function showGroup() { $(groups).each(function() { var group = $(this), elements = $(group).find("[data-animation]"); }); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1

Does using custom data attributes produce browser compatibility issues?

℡╲_俬逩灬. 提交于 2019-12-05 20:25:59
问题 I have to choose between custom data tags or ids. I would like to choose custom data tags, but I want to be sure that they do not cause browser compatibility issues for the most widely used browsers today. I'm using jQuery 1.6 and my particular scenario involves a situation where I need to reference a commentId for several actions. <div data-comment-id="comment-1" id="comment-1"> <a class="foo"></a> </div> It's easier to extract data tags in jQueryin: $('foo').data('commentId'); Extract a

Escape/Special Characters from user input to HTML5 data-attributes using URL Encode/Decode

末鹿安然 提交于 2019-12-05 19:25:42
This is my first question on stackoverflow - needing help from all you experts. Our web app allows the user to input escape/special characters. We are doing some testing for extreme cases. I'm able to pass the escape characters through ajax/json. var test = JSON.stringify({ typeName: $("#typeName").val(), invoiceType: 'NewTypeArea' }); $.ajax({ type: "POST", url: "BackEnd/WebService.php", data: { newInvoice: test }, dataType: 'json' }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> My backend developer does their thing with escape/special characters.