Currently trying to wrap my head around something in OpenCart. It's been years since I have done anything with PHP so having a little trouble. I'm redirecting clicks of href links in to the same div the page is in but some href links need to be ignored because they add elements to the page. I'm ignoring them with a not() selector via my own class I am adding to links I want to ignore, though having trouble adding a class to some links.
For example on the products form for adding products there's an option tab which lets you add different options such as check boxes and date/time. The drop down menu for adding these options has some href links that I can't seem to figure out how to add a class to.
Here's a pastebin to the product_form.php: http://pastebin.com/Fchxw8XG
Here's a look at the actual pages html through chrome dev tools:
I just need to figure out how to add a class called navtab to these dropdown links so I can ignore them.
答案 0 :(得分:0)
所以我想通了,我甚至不需要直接对URL做任何事情。相反,我只是检测在该div中单击链接的时间(选项下拉列表是其中的唯一链接),我在点击时添加一个类,然后处理我的其余脚本。
这是我原来的;
$("#products").on("click", "a:not(.navtab, #)", function (e) {
$("#products").load($(this).attr("href"));
e.preventDefault();
});
所以它会忽略与类navtab的任何链接,但是我需要在运行之前添加该类,我运行它:
$(function(){
var option = $('#tab-option');
option.delegate('a','click',function(){
option.addClass('navtab');
$(this).addClass('navtab');
});
});