我试图在bootstrap中实现一个词缀.它不应该是一个问题,但我想让它响应.
当页面调整大小时,一些元素将隐藏在页面顶部,并且由于宽度的变化,我需要重置词缀并设置为新位置.
我只是搜索它,并找到了一个公认的解决方案,但似乎它不起作用.
这就是我尝试过的:
$(window).off('#myAffix');
$('#myAffix').removeData('bs.affix').removeClass('affix affix-top affix-bottom');
$('#myAffix').affix({
offset: {
top: function () {
console.log('Offset top from: ' + $('.navbar').offset().top);
return (this.top = $('.navbar').offset().top);
}
}
});
Run Code Online (Sandbox Code Playgroud)
我正在呼吁它document.ready和window.resize事件.
我已经为它创建了一个演示.这是步骤,如何重现问题:
当你打开它时,调整reult窗口的大小,同时在边框词缀前有2列,然后重新加载页面.向下滚动时,您将看到,词缀在需要时开始工作.
仅保留左列时调整窗口大小.Affix现在也有效.
再次调整窗口大小,同时显示右列.现在,当它到达前一个位置时,它会触发左列的高度.那很不好.
看来,我的代码正在运行,但对词缀没有任何影响.
PS:不关心词缀的位置,我只是想修复,何时/何地将被修复.
也许我不想做我想做的事,我只是希望.如果没有,没有问题,我会写一个班级.我只想避免这种情况.
当然,我试图在网上搜索答案.我在SO和jQuery论坛上找到了一些东西.喜欢这个,或者这个,或者这个.
但我想以不同的方式做到这一点:
我想直接调用它,我不想使用eval!
我认为做这样的事情
var target = '#id';
var method = 'removeClass';
var className = 'classToShow';
$(taget).method(className);
Run Code Online (Sandbox Code Playgroud)
我得到这个:
TypeError: $(...).method is not a function
[Learn More]
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
我正在开发 Symfony 4 命令,当它完成时我想返回成功或失败代码。
这是文档。
它说:
// return this if there was no problem running the command
// (it's equivalent to returning int(0))
return Command::SUCCESS;
Run Code Online (Sandbox Code Playgroud)
使用Symfony\Component\Console\Command\Command。
我检查过该文件,没有SUCCESS常数。
我错过了什么吗?
单击按钮时,我有以下 js 代码:
$("#processCategories").click(function () {
console.log('HERE');
$.ajax({
url: ajaxUrl, // point to server-side PHP script
data: {action: 'processCategories'},
type: 'post',
done: function () {
console.log('SUCCESS');
//location.reload();
},
fail: function (msg) {
console.log('FAIL');
},
always: function (msg) {
console.log('ALWAYS');
}
});
});
Run Code Online (Sandbox Code Playgroud)
在我的 php 文件中,我添加了下一行:
header('HTTP/1.0 404 Not found');
die();
Run Code Online (Sandbox Code Playgroud)
我也用禁止尝试过。
因此,控制台日志:HERE,但不是FAIL,也不是ALWAYS
我正在使用这个:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
该文件说:
弃用通知:jqXHR.success()、jqXHR.error() 和 jqXHR.complete() 回调从 jQuery 1.8 开始弃用。要为最终删除代码做好准备,请改用 jqXHR.done()、jqXHR.fail() 和 jqXHR.always()。
如果我将这些重写为errorand complete,它们都在运行。
我想念什么?
更新 …
我有一个名为的界面 IUser
我有两个模型,User并且Guest它们都实现了IUser
我有一个类,称为CardOut有两个属性,Card和User
这是CardOut类的构造函数:
public CardOut(Interfaces.IUser User, Card Card) {
this.User = User;
this.Card = Card;
}
Run Code Online (Sandbox Code Playgroud)
我从数据库中获取了一些行,并根据单元格的类型,我创建了一个User或一个Guest.
foreach (IDictionary<string, string> row in rows) {
if (row["type"] == "xxx") {
User UserValue = new User();
UserValue.buildById(int.Parse(row["user_id"]));
} else {
Guest UserValue = new Guest();
UserValue.buildById(int.Parse(row["id"]));
}
Card Card = new Card();
Card.buildCardByIndex(int.Parse(row["cardindex"]));
CardOut CardOut = new CardOut(UserValue, Card); //Here is the error
} …Run Code Online (Sandbox Code Playgroud)