Twitter Bootstrap Tabs: Go to Specific Tab on Page load - ruby-on-rails-3

On my home page, there is a link to user's show page
<a id="event_shortcut" href="http://localhost:3000/users/1#event_tab">show events</a>
and in user's show, I used bootstrap tab,
<ul id="user_show_tabs">
<li >
Profile
</li>
<li>
Events
</li>
<li class="active">
Account
</li>
</ul>
When I click on the link it should go to the user's show page and the event tab should be in foucs.
So in js I did like this,
$("#event_shortcut").live("click", function(event){
event.preventDefault();
window.location = $(this).attr("href");
$('#user_show_tabs a[href="#event_tab"]').tab('show');
});
this js code redirects the user to the show page but the event tab is not set focus.
I don't know what I am missing. Help me!

When you redirect to another page, the tab list is getting refreshed. You either need to put in logic to only have the class="active" on the tab for the current page, or you need to use the tab-content method and have all of the pages load in separate content divs, so the tabs don't actually leave the page they just change which <div> is being displayed.
Check out the Javascript section of Bootstrap to get more info on how to do this. http://twitter.github.com/bootstrap/javascript.html#tabs

in the view(this is haml)
%ul
li{:class => "#{check_if_active('release')}"
= link_to "release", part_release_path(#current_organisation, #part)
and in helper
def check_if_active(tab)
case params[:controller]
when "parts"
if ['release'].include?(params[:action])
tab == "properties" ? "active" : "null"
end
end

Related

Aurelia and Multiple Levels of Navigation

I'm building Aurelia app and I have a top navigation for my app built using the router for high level navigation. I also need a separate side navigation for different sections of my app (per-directory).
For instance I have a users section on the site which will have multiple pages (views and view models) in it for different functionality and I need that users section to have it's own side navigation. I would like to have a separate router and navigation side bar per section. The getting started guide shows a child router scenario, but it's only on a given page.
I'd like my app structure to look something like this:
+src
+users
- home.js
- home.html
- users-nav-bar.html (this is what I'm unsure how set up)
- users-nav-bar.js
- users-router.js (not sure if this is possible)
- user-profile.html
- user-profile.js
- user-roles.html
- user-roles.js
+cases
- case-nav-bar.html
- case-nav-bar.js
etc...
Is this possible with Aurelia? Is there another/better way to structure a side nav-bar per section of the app? Can anyone point me to an example?
Definitely possible, I have it working in my sample app. Here is what I have done. Note that this is just a child router\navigation, I have separate nav-bar for the whole app, and this router\navigation is displayed only if the user clicks on the profile page.
//profile.js
export class Profile {
//Business logic related stuff, interact with services, etc
//then
configureRouter(config, router){
config.map([
{
route:["","about-me"] ,
moduleId:"profile/about-me",
title: "About Me",
name : "about-me",
nav:true
},
{
route:"my-travels",
moduleId:"profile/my-travels",
title: "My Travels",
name :"my-travels",
nav:true
},
]);
this.router = router;
}
}
//profile.html
<div class="panel panel-body">
<div class="wizard text-center">
<a repeat.for="row of router.navigation"
class="${row.isActive ? 'active' : ''}"
href.bind="row.href">${row.title}</a>
</div>
<router-view></router-view>
</div>
So without seeing the code, I can only offer suggestions.
Don't worry about having a separate navbar and router class for each child section. for instance, users-navbar and users-router does not sound right to me (again, I am guessing without seeing the code) but if you have just a users.html and and a users.js, you can include your view-model logic AND router information within users.js. Then all users.html does is loop through the configured routes and display a navigation menu. So unless the user clicks on the link which gets him\her to the users page, that navigation menu will not be visible.

Bootstrap 3: Replacing a modal when one is already open

I have a set of buttons that each can open the modal. The first one opens fine, but if you don't close the modal the second one fails with 'Uncaught TypeError: undefined is not a function.
I have a bunch of links:
<a data-toggle="modal" data-dismiss="modal" data-target="#modal-form" href="partial/forums-modal.html">Open Modal A</a>
<a data-toggle="modal" data-dismiss="modal" data-target="#modal-form" href="partial/facebook-modal.html">Open Modal B</a>
I tried: Twitter Bootstrap open modal over an already opened modal
Not a big help either. Hiding a previous modal when opening a new one.
Yes I have jquery loaded before bootstrap.
The fix for the first error 'Uncaught TypeError' was to upgrade from bootstrap 3.1.1 to 3.2.0. Once this is done, clicking on the second div, the modal closes rather than staying open with the new content.
To update the content, I went down the ajax path. These modals are themselves loaded by ajax (mobile-first and they aren't mobile). Therefore, in a similar vein to Reload Content in Modal Twitter Bootstrap I used the following code:
$('body').on('click', 'a[data-target=#modal-form]', function(ev) {
console.log("clicked");
ev.preventDefault();
var target = $(this).attr('href');
$('#modal-form').load(target, function() {
$('#modal-form').modal("show");
});
});

VB.net clicking a submit button using Web Browser

I want to click the submit button of the webpage i am displaying in my Web Browser but it seems not to work at all here is my code:
WebBrowser1.Document.Forms(0).InvokeMember("image")
i was basing on the html code of the button i want to click which is:
<div class="buttonRow forward">
<input type="image" src="includes/templates/template_default/buttons/english/button_send.gif" alt="Send Now" title=" Send Now ">
</div>
did i miss something? i really need help.
Try setting this property
Webbrowser.AllowNavigation = True

Google+ Sign-In button custom image

I've implemented Sign-In using Google's tutorials, but the button doesn't really fit in with the design of the website I'm using it in. I'd like to use an image my graphic designer made instead. Is it currently possible to use a custom image for Sign-In buttons?
You can use gapi.signin.render to render a specified container as a sign-in button.
For example if in your HTML code you have:
<button id="mySignIn">SignIn</button>
The Javascript call would be something like:
gapi.signin.render("mySignIn", {
'callback': signinCallback,
'clientid': 'CLIENT_ID',
'cookiepolicy': 'single_host_origin',
'requestvisibleactions': 'http://schemas.google.com/AddActivity',
'scope': 'https://www.googleapis.com/auth/plus.login'
});
Also, remember to follow the branding guidelines.
The following code is used to add the login button to the page right?
<span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="CLIENT_ID"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>
Have you tried to simply replace the class "g-signin" with your own class??
If g-signin is required for google themselves, to determine which is the actual signin button, you could always add a subclass to it.
<span class="g-signin custom" ...></span>
In your CSS this would be shown as:
.g-signin .custom {
/*properties*/
}

How do i alter the name of a default home page in the breadcrumb in sharepoint 2010?

I'm customizing a team site in SharePoint 2010 and have been tweaking the breadcrumb to include a link back to the root. Now it says "Home > Home" for the main site and all subsites. How do i rename the home page so that it isn't called "Home" in the breadcrumb?
I tried creating a new page and naming it the way i wanted, and it worked until i set it to the home page. SharePoint overrides your title name with home EVERY time. Anybody know a way around this so that i can turn this automatic renaming off? I'm open to hacks.
If jQuery is an option for you then use it. You will need to construct the selector to get to the Home node and replace it with whatever text you need. For example,
Let's assume you have the following HTML for the breadcrumb:
<ul class="breadCrumb">
<li class="breadCrumbNode"><a title="Home" href="">Home</a></li>
<li class="breadCrumbNode"><span class="breadCrumbArrow"> > </span></li>
<li class="breadCrumbNode"><a title="Page1" href="">Page1</a></li>
<li class="breadCrumbNode"><span class="breadCrumbArrow"> > </span></li>
<li class="breadCrumbNode"><span class="breadCrumbCurrentNode">This Page</span></li>
</ul>
Your JavaScript would be:
$(document).ready(function (){
$('.breadCrumbNode>a[title=Home]').text('New Title for Home Page');
});
See the example here (jsfiddle.net)