我有这个jquery函数
function example(file, targetwidget, callback){
$(targetwidget).load(file, {limit: 25}, function(){
$("#widget_accordion").accordion({fillSpace: true});
});
}
Run Code Online (Sandbox Code Playgroud)
我做的时候工作正常:
example('http://example.com/', "#divid", callback);
Run Code Online (Sandbox Code Playgroud)
但我想在(回调)变量中发送回调函数,即:而不是对接$("#widget_accordion").accordion({fillSpace:true}); 在我想发送的回调函数内:
example('http://example.com/', "#divid", '$("#widget_accordion").accordion({fillSpace: true});');
Run Code Online (Sandbox Code Playgroud)
然后函数必须是这样的:
function example(file, targetwidget, callback){
$(targetwidget).load(file, {limit: 25}, function(){
callback;
});
Run Code Online (Sandbox Code Playgroud)
但那不起作用
在此先感谢您的帮助
我有这个数组:
Array
(
[1] => animal
[1-1] => turtle
[1-1-1] => sea turtle
[1-1-2] => box turtle
[1-1-3] => green turtle
[1-1-3-1] => green turtle with brown tail
)
Run Code Online (Sandbox Code Playgroud)
我想要一些如何将其转换为:
Array
(
[1-title] => animal
[1-sons] => array(
[1-1-title] => turtle
[1-1-sons] => array(
[1-1-1] => sea turtle
[1-1-2] => box turtle
[1-1-3-title] => green turtle
[1-1-3-sons] => array(
[1-1-3-title] => green turtle
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
或者你可以建议一个更好的方法来组织输出的数组..
但是怎么做?
我知道这根本不是一件容易的事,我正在编写一个解析器来处理数据并从中创建树.
在此先感谢您的帮助和建议..