Skip to content

Instantly share code, notes, and snippets.

@crisu83
Last active December 13, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crisu83/4986778 to your computer and use it in GitHub Desktop.
Save crisu83/4986778 to your computer and use it in GitHub Desktop.
Namespaces and input ID selector issue.
<?php
// Attribute id:
frontend\models\UserRegisterForm_profile:availabilityDate
// jQuery selector before escaping:
#frontend\models\UserRegisterForm_profile:availabilityDate
// jQuery selector after escaping using the snippet below:
frontend\\\\models\\\\UserRegisterForm_profile\\:availabilityDate
$selector = '#' . WhHtml::getOption('id', $this->htmlOptions, $this->getId());
$selector = str_replace('\\', str_repeat('\\', 4), $selector);
$selector = preg_replace("/([!\"%\$'\(\)\*\+,\.\/:;<=>\?@\[\]\^\{|\}~]+)/", '\\\\\\\$1', $selector);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment