I've have a menubar item with the name Activity which on hover prints Items and Lists. The code belonging to the menubar item Activity is shown below:
<li>
<section>
<div style="width:100%;">
<?=$ab_string['activity']; ?>
</div>
<div class="sm">
<div class="span">
<ul>
<li><?=$ab_string['items'];?></li> // Line A for dropddown Items
<li><?=$ab_string['lists'];?></li> // Line B for dropdown Lists
</ul>
</div>
</div>
</section>
</li>
On doing hover to Activity menubar item, it shows dropdown Items and Lists. On clicking dropdown Items, I am seeing the blank page.
Problem Statement: I am wondering what changes I need to make at Line A so that it doesn't show blank page on clicking Items.
<?=$ab_string['items'];?>
<?=$ab_string['lists'];?>
Put the variable to the href, and using $_GET['data'] to retrieve the value.
Related
I have an "index.php" page to display all posts from database in a LEFT div as follows:
<div class="col-md-6" id="left">
<a id="link" href="post.php?id=<?php echo $postid;?>"><?php echo $submsg;?></a>
</div>
Also, I have a RIGHT div on same page to expand post when user click on the post link to "read more, comment, like.." as follows:
<div class="col-md-6" id="right">
</div>
And I have a "post.php" page to load it into the RIGHT div..
And I have this Jquery script:
<script>
$("a#link").click(function(e){
e.preventDefault();
$('#right').load(this.getAttribute('href'));
});
</script>
Everything is fine but there's only one problem which is the href of the page is always "index.php" and I want it to changes into the post link when It display in the RIGHT div.
How can I do it?
Thanks in advance.
The following is a foreach loop that will show a group of buttons coming from DB.
#foreach($acc as $accs)
<div class="col-xs-1">
{{$accs->first_name}}
</div>
#endforeach
As I click on one of the buttons, I want to show a new view with all same buttons but ONLY the selected button highlighted (e.g. class="btn btn-warning"). If I add the below code in the new view, all buttons will be highlighted, not only the selected one.
Any idea how can this be done?
#foreach($acc as $accs)
<div class="col-xs-1">
{{$accs->first_name}}
</div>
#endforeach
You should add a new property for that button like $is_highlighed in the controller send to the view and in view make an if statement for finding this button
you have two way for this goal
add a new field in DB like is_highlighed (Boolean)
or
you can add a property in the controller
for example, you get a collection from DB by the model and have some values like id, text, color and etc
and you want to make highlighted blue button so in the controller, you check the color and if button color is the blue that adds an is_highlighed = true
I am on my way trying to get Masonry running with InfinitScroll. I found out that I need the appended method in Masonry. Example:
http://codepen.io/desandro/pen/nhekz
This doesn't work properly because everytime I hit the append button, my Wordpress page reloads. The console says:
Updating because HTML element modified
After the reload all my added DIVs are gone.
Can someone help?
The Problem was a html Element which forces a page reload.
<h1>Masonry - appended</h1>
<p><button id="append-button">Append new items</button>
<div class="masonry">
<div class="item w3"></div>
<div class="item h2"></div>
<div class="item h4"></div>
</div>
I used a div element insted of the button to add masonry elements and the problem was solved
<div id='test2'>click</div>
In my custom WordPress theme, I placed my Cart icon in the header.php, where with other things I placed it in an <li class="user-cart">. I placed the db Query within this <li> and with the "Add to Cart" button I'm trying to reload the <li> so that it can query again and show the updated count of the products added.
On AJAX success I can do it using:
success: function (data) {
$('.user-cart').load(window.location.href + ' .user-cart');
}
When I'm clicking on the Add to Cart button, it's reloading the <li> with the update count(), but it's taking another <li> within the parent <li>, like:
<li class="user-cart">
<li class="user-cart">
<span class="user-cart-icon"></span> 15
</li> <!-- cloned li -->
</li> <!-- parent or original li -->
But the good part is that, the cloned <li> loads only once, on the first click after a page reload, then all the count comes within the second <li>.
What's the wrong part in my code? I don't want any duplicate <li> — just want to reload the <li class="user-cart">.
You should try like this
success: function (data) {
$('.user-cart').load(window.location.href + ' .user-cart a');
}
P.S what does that response data contain? I would prefer to use that to update the count, without making an additional request to server
the page url is http://example.com/index.php?main_page=index&Path=<?php echo $_GET['Path'];?>
there are some contents on the page:
<div>price </div>
<div> the content....</div>
if i click the price, the content will be arranged according to the price with ascending.
<div>price </div>
<div> the content....</div>
if i click the price, the content will be arranged according to the price with descending.
now, i want to get when the visitor click the price text, the content arranged can be exchanged. the default state is ascending. and don't refresh the page.
how should i do?
Can use JQuery load to assign the html from the url without reloading the page.
On the click the on the price link you can load the content div.
e.g.
$('#content_div').load($('#a_price').attr('href'));
For html below -
<a id="1d" href="example.com/index.php?main_page=index&Path=<?php echo $_GET['Path'];?>&sort=1d">1d</a>
<a id="1a" href="example.com/index.php?main_page=index&Path=<?php echo $_GET['Path'];?>&sort=1a">1a</a>
<div id="productListing" />
Javascript -
$('#1d, #1a').click(function(event){
// Prevent default link behaviour
event.preventDefault();
// load the div contents from the link
$('#producListing').load(this.attr('href'));
})
Have added the ids to the link. Can be made generic.
Also, the link contents should render partial content only with the results, which you would need to display.