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: http://i.imgur.com/SwqO1Tp.png
I just need to figure out how to add a class called navtab to these dropdown links so I can ignore them.
SInce the class name is called navtab, you could pull the href link by using this jQuery statement:
This will popup every click event you use on the navtab class. If you want to remove the popup box, simply remove the alert line. From the defined navtab variable, you could add IF statement for all the URLs you want to pull or you could use AJAX to call PHP in order to pull valid URLs from a PHP array.
Code: Select all
navtab = $('.navtab').attr('href');
alert(navtab);
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Not sure I really understood, I don't think that really helps what I am trying to do however it did give me an idea of how I could fix the problem. So instead of finding where the href links are created I instead put in a little script that detects when links are clicked in that div and adds a class to them, and then my other script I am using to load all links to other pages within the same div ignores these links.straightlight wrote:SInce the class name is called navtab, you could pull the href link by using this jQuery statement:
This will popup every click event you use on the navtab class. If you want to remove the popup box, simply remove the alert line. From the defined navtab variable, you could add IF statement for all the URLs you want to pull or you could use AJAX to call PHP in order to pull valid URLs from a PHP array.Code: Select all
navtab = $('.navtab').attr('href'); alert(navtab);
So this is my solution:
Code: Select all
$(function(){
var option = $('#tab-option');
option.delegate('a','click',function(){
option.addClass('navtab');
$(this).addClass('navtab');
});
});
Code: Select all
$("#products").on("click", "a:not(.navtab, #)", function (e) {
$("#products").load($(this).attr("href"));
e.preventDefault();
});
Technically, you did added this line:
to your code which my example post above demonstrates. Glad you found the answer to your own discovery.
Code: Select all
$("#products").load($(this).attr("href"));
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Ah yeah, thanks for giving me a nudge in the right direction. Not sure I would of figured it out otherwise!straightlight wrote:Technically, you did added this line:
to your code which my example post above demonstrates. Glad you found the answer to your own discovery.Code: Select all
$("#products").load($(this).attr("href"));
Who is online
Users browsing this forum: No registered users and 179 guests