I am set with a few different tasks. I need a pop up showing loading til the next page which needs the value that the current HTML img has in the onclick even. I have managed to display the loading image but it is on the parent page and not in a pop up, it will show loading then reset the parent page. There is an option to pick multiple values 1-3 but they are all going to the same onclick even in the HTML on the image
onclick="HRT.CODE(1)", onclick="HRT.CODE(2)" ect...
Not much to go on code wise
Currently I am have the following,
HTML
$("a").click(function() {
$(this).after("<img src='Images/loading-logo.gif' alt='loading'/>").show();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img id="RCLookup" name="RCLookup" alt="" src="images/search_icon_resize.png" onload="" onclick="fCW.fS(1);" />
So I tested the theory of the next page displaying with out a value and duplicating the behavior I am getting with the code I currently have and although it needs a value the next page will not even display and I am getting errors in the console. So leaves me to just put the loading img in a separate pop up while the next page is loading and still pass the value from the onclick even in the img HTML to the next page. Maybe an onclick="function(1)" passing to some JS to show the pop up image then call fCW.fS(val) from the function??
Related
This is what I have:
I have a gridcontainer with three cells where one cell contains three buttons. Each button displays an image below the container.
My javascript code is supposed to make the image disappear if a button is pressed twice butdoes not do so atm. The only way to make it disappear is to either press another picture hence replacing it with a new pic or reload the page.
This is what I want to do:
Instead of replacing and hiding images, I want to replace and hide gridcontainers. So instead of buttons showing pictures they will show a couple of cells with a mix of text and images. The content and layout on this will change when a new button is change, and will totally disappear when the same button is pressed twice. Is this doable.
This is my current javascript:
function changeImage(element){
if(document.getElementById('imageReplace').src==element){
document.getElementById('imageReplace').src="";
} else{ document.getElementById('imageReplace').src=element; }
it is activated by this html:
<div class="cell"><h2>Top reasons you should have a digital self
defense</h2>
<button class="infobutt"
onclick="changeImage('survcap1.jpeg');">Intellectual
freedom</button>
<button class="infobutt"
onclick="changeImage('survcap2.jpeg');">protect vulnerable
groups</button>
<button class="infobutt"
onclick="changeImage('survcap3.jpeg');">Take control over your
life</button></div>"
and correponds further with this html (Situated outside and below the container, also below main tag):
<img src="" alt="Images" id="imageReplace"/>
What is wrong with my current code and how can I improve it to suit my purpose?
I have create an html page containing google map and some text boxes.
I have also created another page in which I have included this page using the include function in php.
<div id="map">
<?php include 'myMap.html'; ?>
</div>
When the page is loaded the map and the other items are correctly loaded and displayed.
Now I have created a button to toggle the visibility of the <div> within which the map has been included. Initially the map is hidden using the hide() function in jQuery.
When I click in the button, the <div> should be visible again. to achieve this, I have called the show() method in jQuery.
But when the button is clicked, everything is shown on the page, but the map is not showing up.
This part of the page in a different html page.
When it is included it is displayed correctly but once hidden and button is clicked for it to show up again, the map becomes like in the picture. I tried a different approach and I have noticed that calling the function that loads the map at the time the button is called can help. Can I call that function found in another html file into the one in which it is included ?
I'm guessing this is caused due to the fact that you're initially hiding the div. Therefore it has no height and when you toggle the visibility of the div it shows a container with a 0px height maps-container.
Try placing your Google Maps code in a function like initMap() or whatever you prefer to call it. After calling $('#your-div').show(); call initMap(). Like so:
$(document).on('click', 'button#your-button', function() {
$('div#your-div').show();
initMap();
});
I think this will solve your issue. If not, you'll have to provide more code to better understand the issue.
From what I've read, jquery.attr() is what I need to update the data-attributes of this div. The div contains an audioplayer on the page and the ultimate goal is to update the data-thumb, data-source, data-bgimage, etc. for a div called "ap1"--for now, let's just target successfully updating data-source which contains the location of the mp3 we want to switch to (string).
I am using the following code that is successfully updating the value (per the alert replying 'sounds/song_to_change_to.mp3') however the corresponding player is not being fully updated--only the text-based components are updating in the view but a 'refresh' isn't occurring for the data attributes:
$('#ap1').attr("data-source", r_cont);
alert($('#ap1').attr("data-source"));
r_cont contains a simple string such as 'sounds/song_to_change_to.mp3'.
When the alert runs it shows the name of the new mp3 but the player does not update. Note here that text components are updating in the html (such as $("#activeartist").text(title);) and the changes are viewable immediately. The code I am using initiates the player using the following:
jQuery(document).ready(function ($) {
var settings_ap = {
disable_volume: 'off'
};
dzsap_init('#ap1',settings_ap);
});
I have inserted this into a function which runs when a link is clicked to update the current song playing. The same identical function is used in a script tag right before the </body> to initialize the player with a default song on page load.
This is the div in my html code that presents the original player (with a default song).
<section class="dzsap-sticktobottom">
<div id="ap1" class="audioplayer-tobe" style="width:100%; margin-top:10px; margin-bottom: 10px;" **data-thumb**="img/thumb2.jpg" **data-bgimage**="img/bg.jpg" **data-source**="sounds/itsabeautifulday.mp3">
<div class="meta-artist"><span id="activeartist" class="the-artist">Artist Name</span><span id="activesong" class="the-name">Song Name</span>
</div>
</div>
</section>
When the function runs, the goal is to update the player with the selected song and associated bg image, thumbnail, etc. The function takes as input 6 strings and passes them along but let's for now just pretend it will take as input 1 string which contains the mp3 path.
Note: I'm wondering if ap1 needs to be torn down and reinitialized each time. I tried to use $('#ap1').remove() in the function to tear down the existing div each time a link was clicked and then append the entire div with $("#ap1").html('HTML_AP1_CODE_HERE>') but it only came through as unformatted text.
Say I have a left-side chat bar with chat users. Each user has their image (much like Facebook's chat)and is clickable to open a chat box to start chatting away.
Here's my code:
$('.msg_wrap').hide();
$('.msg_box').hide();
$('.chat_user').click(function() {
$('.msg_wrap').show();
$('.msg_box').show();
}
I know this is wrong but what I want to do here is when the page loads for the first time, all the chatboxes to be hidden (hide ()). It is not until I click on a chat user (.chat_user) that a pop up/chat box appears (show()). How do I fix this code? Do I have to create a function?
A quick thought on a solution.
First. Set the elements ('.msg_wrap') and ('.msg_box') to hidden in your html and kill your first two lines of code. I am not sure what those elements specifically are, but, for example, if they were div tags it would look something like:
<div hidden class="msg_wrap">
Second. I am not sure if you are saying that the code currently isn't working on page load. It looks like you are missing a ) at the end and also you can update to the following so that it gets executed on page load.
$(function(){
$('.chat_user').click(function() {
$('.msg_wrap').show();
$('.msg_box').show();
});
});
This is jquery shorthand for $( document ).ready().
Also, if you want the msg_wrap and msg_box elements to toggle between being hidden and shown you can use the toggle() method instead of show().
can I cache an empty form template as a second page in browser cache
so that when you click "create event" button on first page it immediately
opens empty form template without having a need to download the template
from the server as it's cached.
Just like CREATE EVENT button in Google calendar; which let's you to switch between calendar and new event form template.
Well, you can either use Javascript for building the new page from scratch when the respective action is invoked (probably quite tedious) or you can use an invisible section (e.g., a separate <div>) of the HTML page (style = display: none) and make it visible by changing its class to a visible style and making the original page invisible (change its style to display: none).
One way to accomplish this would be to load your second view into a hidden container. You can hide it with a simple CSS display property toggle, like this:
<div id="mySecondView" style="display: none;">
<!-- content of second view here -->
</div>
And on button click you can do this to unhide it:
With jQuery:
$('#mySecondView').show();
or
$('#mySecondView').fadeIn();
Without jQuery:
document.getElementById('mySecondView').style.display = '';
Of course you'll have to position the second view via CSS as you want it, otherwise it'll just pop up in some weird place that won't make sense.