jQuery selector for uncommon tag ID - jquery-selectors

I have this tag ID, pretty uncommon:
<select name="/State" id="/State">
It seems I cannot use jQuery selector $('#/State') to select this object.
I can select it using $("#\U002FState"), but I cannot print the id attribute:
javascript:alert($("#\U002FState").attr('id'))
What can I do to correctly select this object?

add \\ before / $('#\\/State')
Additional links:
jQuery selectors: http://api.jquery.com/category/selectors/
W3C recommendation: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier

as explained here / is not a valid character in id's, so your tags are not standards compliant and it's better to fix that problem than to work around it.

Unless you're only supporting HTML5 browsers, you'll have issues when selecting by ID, because a / in an ID is not valid in HTML4.
http://www.w3.org/TR/html401/types.html#type-name
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
You could use the attribute-equals-selector[docs], but performance will degrade:
$('select[id="/State"]');
Though it's helpful to include the element-selector[docs] as I did above.
Here's a working example: http://jsfiddle.net/LVEjS/

Related

Polylang: How does the linking of right page by changing the attribute "href" work?

I have a question about linking the right page with Polylang.
I have a hard-coded anchor, which is basically a “back home” link.
It looks like this:
<a href=“magazin” class=“article-type-inner”><?php pll_e(‘Close’); ?></a>
I have already implemented a string and it works fine in the posts in both languages, but how can I change the “Href” to the right language?
For example my default language is English and the other language is French. If I am on a french post I will return to the English page… Is there any solution?
Thank you.
Ideally you should not hardcode any strings or URL's, here is some options for you:
Use pll_home_url() if your intention is to redirect to the home page. pll_home_url() accepts optional parameter $slug (2-letters code of the language) to switch between languages if needed.
Use get_permalink(), the_permalink() or get_the_permalink(). You can pass page_id as first argument. Make sure post/pages/cpt's are linked properly. E.g. the_permalink(100).
Worst case scenario - use if/else in combination with pll_current_language(). Not recommended.

How to customize email template in crm 2016 by code

I am using CRM 2016, and trying to customize email template by adding a dynamic data. I know that CRM allows to use only specific vanilla entities, but when I explorer an old code I found an option to use {0}, {1} etc' for injecting data from non vanilla entities (by code) - unfortunately that code cannot be tested...
Have someone heard or know about that way? is it possible? what to google for?
You can do this by manually typing similar marker what CRM is using. Note that this is not documented in SDK.
Dynamic Values For Custom Entities In Email Templates
In the template, where you want the value to appear, type within 2 brackets an exclamation point followed by the entity logical name. After the entity name, add a colon, and then the field logical name, ending it with a semi colon. If you’d like a default value if nothing was found, after the semi colon add the default value.
{!<entitylogicalname>: <fieldlogicalname>; <Default Text>}
More in part 2:
The Global Template Type is what you’d want to use for custom
entities, or any other entity not listed in the template type drop
down menu. And just to reiterate, regardless of the way you insert
values, whether you use the out of the box insert method or you
manually type it in, you can only insert values from one record.
Dynamic Values For Email Templates - Part 2
Dynamics' email templates are flawed. You either can't use custom entities or you have no translation. I use this workflow instead. It can do everything : https://github.com/rtebar/dynamics-custom-emails

Django Tag object

Django Tag object has a default function add_tag(), it seems it only allow one word for the tag name, is there anyway to save a tag contains more than one words?
If you are using django-tagging, you can add tags with spaces by either putting quotes around the tag or using commas to separate the tags. It makes sense in the context of adding multiple tags, but I think it works the same for individual tags too.
Note: The following code is untested
Tag.objects.add_tag(obj, '"banana split"')
Tag.objects.add_tag(obj, 'banana split,')

Access select using div/span id

In jquery is it possible to access a select element by simply using the div or span id plus the "select" selector? I ask because i have a series of auto-generated forms meaning I can't assign an id to the form elements plus the names are weird like "w24", I'd like to access a form element specifically a select using the surrounding span id and "select" selector example:
$("#hiv_care select").attr("disabled",true);
I've tried this but it doesn't work, forcing me to explicitly use the dropdown name.
Seems I was using the wrong div id. SLaks thanks for the link to jsfiddle.net it exposed my ways and is really helping me with testing out my jquery code.

Zend Framework Filter Input StripTags and "<3"

I'm currently using Zend_Filter_StripTags in a commenting system, but stuff kinda breaks when '<3' is entered. StripTags doesn't seem to be smart enough to realize that it's not an HTML tag, and creating the filter as "new Zend_Filter_StripTags(array('3'))" doesn't seem to work either.
Should I pass the input through a regexp first, or is there a way to get Zend_Filter_StripTags to straighten up and fly right?
Ended up writing a Zend_Filter class that was basically a wrapper for HTMLPurifier. Works perfectly, because HTMLPurifier is a LOT smarter than striptags.
I'm not familiar with Zend much, but if you want stuff like <3 to be allowed, just do htmlspecialchars instead of strip_tags on it.
What you want is Zend_Filter_HtmlEntites most likely.
See: Zend_Filter_HtmlEnties
The problem with htmlspecialchars and Zend_Filter_HtmlEntities is that if you're trying to strip out all html tags ( like 'a' and 'img', etc ), then instead of stripping them, you end up with that markup in your output.
Take comments on a blog for example. If you use htmlspecialchars or Zend_Filter_HtmlEntities, in a comment where someone tries to use html to enter a link you end up with that markup showing up when you display the comment. But if you use strip_tags or Zend_Filter_StripTags you end up mangling the comment, as neither is smart enough to realize that '<3' isn't a tag, and just strips everything from '<3' until the end of the comment ( or until it finds '>' ).
It would be nice if Zend had something like HTMLPurifier, where it actually checks and validates the input before stripping tags. This means that stuff like '<3' gets left alone, where as stuff like 'Awesome Site' becomes 'Awesome Site'.
This is a problem I'm trying to work around, and at the moment it seems like I'm going to end up writing my own Zend_Filter class that's basically a wrapper for HTMLPurifier.