我有一个模态,我弹出jQuery文本字段,我想触发focus()事件.
问题是fextfield IS已经成为焦点.在大多数浏览器中,它甚至都是突出显示的.(我不知道为什么?)
如何解除焦点或取消选择文本以便我可以使用该focus()事件?
<input type="text" class="shortcut" id="input-shortcut" value="<?= $shortcut_url; ?>" />
$(".shortcut").focus(function() {
$(this).addClass("focus");
$(this).select();
}).blur(function() {
$(this).removeClass("focus");
});
Run Code Online (Sandbox Code Playgroud) 我是SQLAlchemy ORM的新手,我正在努力在多个表上完成复杂的查询 - 我发现在Doctrine DQL中相对简单的查询.
我有城市的数据对象,属于国家.一些城市也有县ID,但不是全部.除了必要的主键和外键之外,每个记录还有一个text_string_id,它链接到TextStrings表,该表存储不同语言的City/County/Country的名称.TextStrings MySQL表如下所示:
CREATE TABLE IF NOT EXISTS `text_strings` (
`id` INT UNSIGNED NOT NULL,
`language` VARCHAR(2) NOT NULL,
`text_string` varchar(255) NOT NULL,
PRIMARY KEY (`id`, `language`)
)
Run Code Online (Sandbox Code Playgroud)
我想为每个城市构建一个面包屑,形式如下:
country_en_name> city_en_name OR
country_en_name> county_en_name> city_en_name,
取决于是否为此城市设置了县属性.在Doctrine中,这将是相对简单的:
$query = Doctrine_Query::create()
->select('ci.id, CONCAT(cyts.text_string, \'> \', IF(cots.text_string is not null, CONCAT(cots.text_string, \'> \', \'\'), cits.text_string) as city_breadcrumb')
->from('City ci')
->leftJoin('ci.TextString cits')
->leftJoin('ci.Country cy')
->leftJoin('cy.TextString cyts')
->leftJoin('ci.County co')
->leftJoin('co.TextString cots')
->where('cits.language = ?', 'en')
->andWhere('cyts.language = ?', 'en')
->andWhere('(cots.language = …Run Code Online (Sandbox Code Playgroud) 我需要将HTML转换为等效的Markdown结构化文本.
由于我使用PHP编程,有些人表示Markdownify可以完成这项工作,但不幸的是,代码没有更新,实际上它没有用.在sourceforge.net/projects/markdownify有一个"注意:不支持 - 你想维护这个项目吗?联系我!Markdownify是一个用PHP编写的HTML到Markdown转换器.看它是html2text.php的继承者,因为它有更好的设计,更好的性能和更少的角落情况."
根据我的发现,我只有两个不错的选择:
Python:Aaron Swartz的html2text.py
Ruby:Singpolyma的html2markdown.rb,基于Nokogiri
所以,从PHP,我需要传递HTML代码,调用Ruby/Python脚本并接收输出.
(顺便说一句,一个民众在这里提出了一个类似的问题("如何从php调用ruby脚本?"),但我的案例没有实用信息).
按照Tin Man的提示(下图),我得到了这个:
PHP代码:
$t='<p><b>Hello</b><i>world!</i></p>';
$scaped=preg_quote($t,"/");
$program='python html2md.py';
//exec($program.' '.$scaped,$n); print_r($n); exit; //Works!!!
$input=$t;
$descriptorspec=array(
array('pipe','r'),//stdin is a pipe that the child will read from
array('pipe','w'),//stdout is a pipe that the child will write to
array('file','./error-output.txt','a')//stderr is a file to write to
);
$process=proc_open($program,$descriptorspec,$pipes);
if(is_resource($process)){
fwrite($pipes[0],$input);
fclose($pipes[0]);
$r=stream_get_contents($pipes[1]);
fclose($pipes[1]);
$return_value=proc_close($process);
echo "command returned $return_value\n";
print_r($pipes);
print_r($r);
}
Run Code Online (Sandbox Code Playgroud)
Python代码:
#! /usr/bin/env python
import html2text
import …Run Code Online (Sandbox Code Playgroud) 我正在开发一个使用URLLoader从远程服务器获取信息的Flash应用程序.我有一个函数,它将根据产品ID创建信息请求.当出现错误时,我想回到备用URL,但要创建备用URL,我需要知道产品ID.确定哪个URLLoader失败(以及哪个产品请求失败)以便我可以重新生成新URL的最佳方法是什么?
我的功能如下:
function loadData(productID:String):URLLoader {
var productURL:URLRequest = new URLRequest("/path/to/product/" + productID);
var dataLoader:URLLoader = new URLLoader();
dataLoader.addEventListener(Event.COMPLETE, parseData);
dataLoader.addEventListener(IOErrorEvent.IO_ERROR, handleDataError);
dataLoader.load(productURL);
return dataLoader;
}
function handleDataError(e:IOErrorEvent) {
var productID:String = ???;
var altProductURL:URLRequest = new URLRequest("/alternate/path/to/product/" + productID);
var dataLoader:URLLoader = new URLLoader();
dataLoader.load(altProductURL);
}
Run Code Online (Sandbox Code Playgroud) 我一直在使用js-hotkey,喜欢它.
我现在想绑定?密钥,但似乎不支持.任何人都知道为什么以及如何绑定到?问号?
$(document).bind('keydown', '?',function (evt) {
alert('go');
});
Run Code Online (Sandbox Code Playgroud)
上面的代码不起作用.
就像其他许多问题一样,我正在尝试使用Boost.Spirit.Qi将简单语法解析为结构树.
我会尝试提炼我想要做的最简单的案例.我有:
struct Integer {
int value;
};
BOOST_FUSION_ADAPT_STRUCT(Integer, (int, value))
Run Code Online (Sandbox Code Playgroud)
后来,在语法结构中,我有以下成员变量:
qi::rule<Iterator, Integer> integer;
Run Code Online (Sandbox Code Playgroud)
这是我定义的
integer = qi::int_;
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试实际解析整数时,使用
qi::phrase_parse(iter, end, g, space, myInteger);
Run Code Online (Sandbox Code Playgroud)
myInteger.value在成功解析后始终未初始化.同样,我尝试了以下定义(显然那些不编译的定义是错误的):
integer = qi::int_[qi::_val = qi::_1]; //compiles, uninitialized value
integer = qi::int_[qi::_r1 = qi::_1]; //doesn't compile
integer = qi::int_[phoenix::bind(&Integer::value, qi::_val) = qi::_1]; //doesn't
integer = qi::int_[phoenix::at_c<0>(qi::_val) = qi::_1]; //doesn't
Run Code Online (Sandbox Code Playgroud)
显然,我误解了一些关于精神,凤凰或其他东西的东西.我的理解是,当方括号中的部分作为函数对象执行时,这里qi::_1的第一个属性qi::int_应该表示已解析的整数.我假设函数对象将采用封闭integer属性qi::_val并尝试将解析后的整数分配给它.我的猜测是因为我的BOOST_FUSION_ADAPT_STRUCT调用,两者兼容,从静态分析的角度来看,情况似乎确实如此,但数据并未得到保留.
是否有参考(&)指定我在某处或某处遗漏?
有没有办法用cfset设置一个更像cdata标签的变量
还是有另一种方法可以让页面设置一些基本变量,并为主要内容设置几个较长的变量;
即.
<cfoutput>
<CFSET page_title = "TITLE">
<CFSET examplevariable = "ABC">
<CFSET content>
<!--something like this-->
<div>
bunch of content without any cf tags
</div>
</CFSET>
<cfinclude template="include/layout.cfm">
</cfoutput>
Run Code Online (Sandbox Code Playgroud) 在大多数源代码中,根包/文件夹名为"com".为什么会这样?它只是惯例还是代表什么?
我有一种情况,数据文件中的某些值有64位环绕,这使得它们非常大,比如,18446744073709551608.
所以我必须从2 ^ 64执行减法.我用简单的方法试过这个
2^64 - 18446744073709551608
Run Code Online (Sandbox Code Playgroud)
但我猜这个数字太大而且没有得到实际的答案8.我需要做什么来执行这个减法.
我遇到了WCF REST服务的问题.我明白了:
无法从程序集'System.ServiceModel,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.ServiceModel.Activation.HttpHandler'.
在ASP.NET 4.0 AppPool中运行IIS时.
只有在以下情况下才会出现问题:
在卡西尼号中运行 - 没问题,它可以正常运行.与ASP.NET兼容性运行 - 没问题,它的工作原理.
它似乎是某种处理程序版本冲突试图实例化错误版本的处理程序,而该处理程序反过来试图加载旧版本的System.ServiceModel,但我无法追踪它.
任何人之前都看过这样的事情并有任何想法如何进一步追踪这个?
我查看了ApplicationHost.config和System.ServiceModel和HttpHandler引用的主web.config文件,但没有运气.那里.
+++瑞克---