我正在为我的应用程序使用 mootools v1.3。我已经实现了对 myCSS.php 和 myContent.php 的两个异步调用。首先加载 CSS 并将其附加在
标签的顶部 在 < script > 标签内。然后内容加载到 标签的底部。异步调用是:
var myRequest = new Request({ async: false, method: 'post',
onSuccess: function(html) { /* Code to attach html value in <body> tag */ },
});
myRequest.send({url: myCSS.php});
myRequest.send({url: myContent.php});
在CSS中有一个类
.content_disp {
padding: 10px; border: 1px solid #333; }
在 myContent.php 中:
<div class="content_disp"> some data...... </div>
问题是 CSS 类 .content_disp 的属性没有显示 我不知道哪里出错了...
最佳答案
您应该看看 Mootools More 中的 Asset 类是如何做到这一点的。 css 首先应用于链接元素,然后将其注入(inject)文档头部。从您的示例中不清楚您将原始 css 源插入到哪个元素中。
css: function(source, properties){
properties = properties || {};
var onload = properties.onload || properties.onLoad;
if (onload){
properties.events = properties.events || {};
properties.events.load = onload;
delete properties.onload;
delete properties.onLoad;
}
return new Element('link', Object.merge({
rel: 'stylesheet',
media: 'screen',
type: 'text/css',
href: source
}, properties)).inject(document.head);
},
关于javascript - 如何将附加的 css 加载到 Request 类加载的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4886202/