I am trying to use the jQuery tabbed widget as a menu for my application and have managed to set up the tabbed interface so that when you click a tab it shows the first page of that section. According to the docs, if you click on a link on this page and want it to load in the same tab then you need to use the code below. This partially works because now when I click on an image-hyperlink on that page it renders the new page in the tabbed window.
However, when I click on a button which has javascript the button no longer works. This is the case for all of the javascript. How can I get the javascript working again under the new tabbed interface?
$('#example').tabs({
load: function(event, ui) {
$(ui.panel).delegate('a', 'click', function(event) {
$(ui.panel).load(this.href);
event.preventDefault();
});
}
});
EDIT: So if you add the following line to LeftyX's code in the page 1 file, then the button causes page4.html to open but does not do it in the tab
<button onclick="location.href='Page4.html'">Test button </button>
It must work.
If you show us your HTML we might try to help.
You can check my sample and download the code.
Try and check if there are any errors in your script using some Dev Tools (ex: Google Chrome Developer Tools)
UPDATE:
if you're using a button you can use some HTML5 attribute:
<button data-pagelink="Page4.html">Test button</button>
and trap the click event:
$(ui.panel).delegate('button', 'click', function(event, o) {
$(ui.panel).load(this.dataset.pagelink);
event.preventDefault();
});
or use an hyperlink and transform it in a button:
<a id="thisIsAButton" href="Page4.html">go to page 4</a>
with this:
$("#thisIsAButton").button();
Related
In my web apps are having lots of Popup Window and each window having Toggle buttons are there.
Currently are all open at initial stage, But I need to collape (Closed condition at initial stage).
Problem is all popup pages are having same class name and dynamic id and dynamic attribute. From my end - we cann't use ID and Attribute.
<a class="panel-toggle in" href="#dynamic-value" data-toggle="collapse" aria-expanded="true">
Open/Close
</a>
So I implemented trigger function like this for main layout and later that particular pop html page. Some pages are global.
$(document).ready(function () {
$("body .ui-dialog .panel-toggle").trigger('click');
});
After that above code, on first time load - All are working normal. But i opended second popup from first popup, they collapse all first too.
Later I tried first popup from individual html and second popup is also another individual - but same error. below code for this type
$(document).ready(function () {
$(this).find(".panel-toggle").trigger('click');
});
Any idea... Onpage load, I need trigger for that particular page with global code also individual.
In my application navigator status bar is displayed by default at the bottom of each screen and URLs linked to buttons and icons will be displayed on it.
Like this:
I do not want to show URL associated to hyperlink or button at bottom of the web page using JavaScript.
What I have tried so far:
Setting window.status = '' onmouseover property of hyperlink/button, but this is not working.
Browser I'm using are Internet Explore IE11 and Firefox 38.8.0.
Try this
It's working for me.
I have tested this on both browsers: Internet Explore and Firefox
click here
I do not want to show URL associated to hyperlink or button at bottom of the web page [using JavaScript]
Statusbar shows the href.
So: don't specify an href.
There's no need for javascript to "hide" it.
Given that it's a link you probably want to be able to click it, so add a click handler with jquery and you can style with css to make it look like a link.
$(function() {
$("#saveLink").click(function() {
location.href = $(this).data("href");
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a id='saveLink' title='Click to save' data-href='http://google.com'>no status bar link on hover</a>
<br/>
<a href='http://google.com'>link shown in status bar on hover</a>
If you need keyboard support (tab) then you'll need an href, so can just go with href='#'
I've created my page using bootstrap and have a link to fire off a fancybox box as below:
<a class="iframe" href="AForm.asp?ID=<%=Request("ID")%>"><button class="btn-warning">Action Form</button></a>
JQuery
<script type="text/javascript">
$(document).ready(function() {
$("a.iframe").fancybox({
'type' : 'iframe',
'width':500,
'height':500,
'afterClose':function () {
window.location.reload(); }
});
});
</script>
The default functionality works fine to begin with: i can trigger fancybox to load, click the default cross icon and it closes the box - all working as expected.
When i submit a form within the fancybox (html/classic asp) and it does a redirect to a standard HTML page that literally just says "Please close this page" the default close cross icon does nothing. It is visible and in the correct place but there is no click functionality.
I have tried custom close buttons within the HTML page but nothing works - it just doesn't want to close at all. Anyone got any ideas? Thanks
Not so much an answer but after trying to fix this all day i gave up on Fancybox and found Colorbox to work pretty much out of the box for what i was trying to do. Colorbox
I'm using tabs with Twitter Bootstrap 3 and want one of them to function as an external link that opens a new window. I removed the data-toggle="tab" and added some JQuery to accomplish this. The code below doesn't work and gives me the following error message, however if I add class="active" to the li element, it works perfectly (other than that tab having incorrect styling). Why is this the case? How can I alter my code so I don't need class="active" on the parent li?:
HTML:
<li>
<a href="https://www.google.com/" class="external-link" target="_blank">
<span class="nav-text-wrapper">Example Tab Name</span>
</a>
</li>
Javascript:
$('.external-link').click(function(){
window.open($(this).attr('href'));
});
EDIT:
I found the solution. I had the following JQuery code to allow for nested tabs, but apparently this conflicted with me using external links on tabs
var $mainTabs = $('.tab-menu a');
$mainTabs.click(function (e) {
e.preventDefault();
$(this).tab('show');
});
How about this?
$('a.external-link').on('show.bs.tab', function (e) {
e.preventDefault(); // prevents the default tab selection behavior
window.open($(this).attr('href'));
});
show.bs.tab is an event that gets raised for a tab right before it is shown. By cancelling it with e.preventDefault(), you're interrupting the tab's show() function early on and inserting your own behavior. If you don't stop the show() function early like this, it will try to select the tab panel referenced in your href in order to show it. The error you were getting was because the tab plugin was trying to find a DOM element with a selector like this: $('https://www.google.com').
I'm creating a jQuery Mobile web application.
This link, works correctly:
Click Here 1<!--This is working-->
But, these links which have anchors are not working:
Click Here 2<!--This is not working-->
Click Here 3<!--This is not working-->
How to make those links that have # work with ajax navigation?
Edit: The page, which contains these links, contains some links to different articles. And /ThePage/25 contains the full text of that articles. I want each link to go to somewhere inside /ThePage/25. So I've used #. (#3 means the third article in the page)... Do you know any better way?
Edit 2: I'm simply trying to load/show a page and then jump within it...
Edit 3: My jump inside that page isn't a simple jumping. It's a custom handled jumping with hashchange event. But if there is any other method, I can change that page...
add rel="external" to any links that have an anchor # and you don't want to load via ajax.
New Links would be:
Click Here 2<!--This is not working-->
Click Here 3
See http://jquerymobile.com/demos/1.1.1/docs/pages/page-links.html for more detail.
You can try using this from JS like this , I had problems with # tags :
<a class='homeSet'>Home</a>
....
$('body').on('click', '.homeSet', function(ev) {
$.mobile.changePage('/home.html#myhome', {
transition : "slide"
});
return false;
});