Prado\Web\Javascripts\TJavaScript::quoteString PHP Method

quoteString() public static method

After processing, the string is safely enclosed within a pair of quotation marks and can serve as a javascript string.
public static quoteString ( $js ) : string
return string the quoted string
    public static function quoteString($js)
    {
        return self::jsonEncode($js, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG);
    }

Usage Example

示例#1
0
 public function onPreRender($param)
 {
     parent::onPreRender($param);
     $cs = $this->Page->getClientScript();
     $cs->registerPradoScript('validator');
     // communicate validation status to the client side
     $value = $this->_isvalid === false ? '0' : '1';
     $cs->registerHiddenField($this->getClientID() . '_1', $value);
     // update validator display
     if ($control = $this->getValidationTarget()) {
         $fn = 'captchaUpdateValidatorStatus_' . $this->getClientID();
         $cs->registerEndScript($this->getClientID() . '::validate', implode(' ', array('function ' . $fn . '(valid)', '{', '  jQuery(' . TJavaScript::quoteString('#' . $this->getClientID() . '_1') . ').val(valid);', '  Prado.Validation.validateControl(' . TJavaScript::quoteString($control->ClientID) . '); ', '}', '', $this->Page->IsCallback ? $fn . '(' . $value . ');' : '', '', 'jQuery("#' . $control->getClientID() . '").on("change", ' . TJavaScript::quoteString('#' . $control->getResponseFieldName()) . ', function() { ', $fn . '("1");', '});')));
     }
 }
All Usage Examples Of Prado\Web\Javascripts\TJavaScript::quoteString