I've implemented a Photoshop design into HTML using Bootstrap (my first time with bootstrap). That is a single page website and have 4 sections (actually pages). Every section have multiple pages which I've have showed in Tab Panel using Bootstrap's tabbable class. It's working fine, I want a sliding effect for every tab to display it's content. Means, if a section contains 3 tabs and I click on the 2nd tab, the next tab's content appear as sliding effect. Is there only class name to add?
Thanks.
I think this is about it
<div class="container">
<div class="row">
<div id="tab-container" class="span6 offset1">
<ul class="nav nav-tabs" id="myTab">
<li class="active">Options</li>
<li class="disabled">Information</li>
<li class="disabled">Payment</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="options">
<div class="well">
<form id="frmtype1" action="" name="frmtype1" method="post">
<fieldset>
<legend>Registration Options</legend>
<label for="Reg_type1" class="radio">
<input type="radio" name="Reg_type" id="Reg_type1" value="1"/>
Registering myself with credit card or bank account
</label>
<br>
<label for="Reg_type2" class="radio">
<input type="radio" name="Reg_type" id="Reg_type2" value="2"/>
Registering multiple people using credit card or bank account
</label>
<br>
<label for="Reg_type3" class="radio">
<input type="radio" name="Reg_type" id="Reg_type3" value="3"/>
Registering using a purchase order
</label>
</fieldset>
<button class="btn-demo btn" data-activate="#information">Continue</button>
<span class="help-inline" style="display:none;">Please choose an option</span>
</form>
</div><!--/.well -->
</div>
<div class="tab-pane" id="information">
<div class="well">
<form name="everything" id="frmtype2" action="" method="post"><p>Some content to give this pane a little bit of bulk</p>
<button class="btn-demo btn" data-activate="#payment" type="submit">Continue</button>
</form>
</div><!--/.well -->
</div>
<div class="tab-pane" id="payment">
<div class="well">
<p>Some content for the 3rd pane.</p>
</div><!-- .well -->
</div>
</div>
</div><!-- /.row -->
</div><!-- /#tab-container --> </div><!-- /.container -->
JAVASCRIPT
var selector;
var selectorID;
activateTab('#myTab a:first');
function activateTab(selectorID)
{
$(selectorID).tab('show')
.closest('.disabled').removeClass('disabled');
}
function deactivateTab(selector)
{
$(selector).off('click.twbstab')
.closest('li').addClass('disabled');
}
$('.btn-demo').on('click',function() {
selector = '#myTab a[href="'+$(this).data('activate')+'"]';
selectorID = $(selector).attr('href');
});
var val1 = $('#frmtype1').validate(
{
errorPlacement: function(error, element) {},
// prevent the standard error message from showing, rather you use the inline-text
rules: {
'Reg_type': {
required: true
}
}
});
// validate 1st form
$('#frmtype1').submit(function(e)
{
// validate the first page
if(val1.form()) {
$('.help-inline').hide();
activateTab(selector);
} else {
$('.help-inline').show();
}
return false;
});
// validate 2nd form
$('#frmtype2').submit(function(e)
{
// validate the second page
activateTab(selector);
return false;
});
// if 2nd or 3rd tab is clicked, validate as if the form was submitted
$('#myTab li:eq(1) a, #myTab li:eq(2) a').click(function(e)
{
selectorID = $(this).attr('href');
// validate the first page
if(val1.form()) {
$('.help-inline').hide();
activateTab(this);
$(selectorID).tab('show');
} else {
$('.help-inline').show();
}
return false;
});
// re-position all tab-panes, except the active pane, so that they are prepared for the slide effect
$(".tab-pane").css("position", "relative");
$(".tab-pane").not(".active").animate({
left: "1000px"
});
// perform slide effect
$('a[data-toggle="tab"]').on('show', function (e) {
lastPane = $(e.relatedTarget).attr('href');
$(lastPane).animate({left: "1000px"}, 300)
currPane = $(e.target).attr('href');
$(currPane).animate({left: "0px"}, 300);
});
JSFidle DEMO
Related
I have a button that is taking text entry in an input box and appending to a URL and redirecting.
The entire system is working, however the problem I am facing is when I enter the text and click the button nothing happens. Every time I add text, the button does nothing.
When I dont enter any information, the button takes me to the url that should have the input appended to (wihtout the appended information)
<div class="pen-title">
<div class="container">
<div class="card"></div>
<div class="card">
<form>
<div class="input-container">
<input type="#{type}" id="txt" required="required"/>
<label for="#{label}">Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button id="btn"><span>Go</span></button>
</div>
</form>
</div>
</div>
</div>
the JS:
<script>
var nickname = document.getElementById("txt");
function redirect () {
window.location.href = "https://theurl.com/details?info=" + nickname.value;
};
document.getElementById("btn").addEventListener('click', redirect);
</script>
If I use the JS with the following button settings:
(THE FOLLOWING CODE WORKS AND IS ONLY A DEMO TO SHOW THAT THE FUNCTION IS ACTUALLY WORKING FULLY)
The code with the bug is the code above this line.
<div class ="input"> <input type="text" id="txt" />
<label for="txt"> Enter Reg </label> </div>
<div class="buttons">
<button class="pulse" id="btn">Pulse</button>
</div>
<script>
var nickname = document.getElementById("txt");
function redirect () {
window.location.href = "https://carservicesinreading.co.uk/check-mot-history/details?car-reg=" + nickname.value;
};
document.getElementById("btn").addEventListener('click', redirect);
</script>
it works first time. However the template of this set up was different css for the input box and different CSS for the button and I just cannot get it in the layout I would like.
Thank you for any help!
the only thing i can see as you haven't provided much info. on the button i added type submit.see if i helps as i can see it redirects and says cannot find mot details.do you have real reg no for testing?
update:removed form tags.
var nickname = document.getElementById("txt");
function redirect() {
window.location.href = "https://theurl.com/details?info=" + nickname.value;
};
document.getElementById("btn").addEventListener('click', redirect);
<div class="pen-title">
<div class="container">
<div class="card"></div>
<div class="card">
<div class="input-container">
<input type="#{type}" id="txt" required="required" />
<label for="#{label}">Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button id="btn"><span>Go</span></button>
</div>
</div>
</div>
</div>
I am making a searchfield which triggers a request function returning partial view and according to result I want to show the response in partial view under the searchfield in the same page. User writes something to textfield and clicks the search button then under them result shows. I get the result but my partialview is opening in another page instead of under the searchfield in the same page. Also looks like my onClick function does not trigger.
My main View:
<div class="container">
<!-- Outer Row -->
<div class="row justify-content-center">
<div class="col-6 p-3">
<form class="form-group" method="post" action="/Books/BookDetail">
<div class="input-group">
<input type="text" name="barcodes" class="form-control bg-light border-0 small bg-gray-200" placeholder="Kitap Barkodunu giriniz..." aria-label="Search" aria-describedby="basic-addon2">
<button class="btn btn-primary" type="submit" id="myBtn" name="myBtn" onclick="showBook">
<i class="fas fa-search fa-sm"></i>
</button>
</div>
</form>
</div>
<br />
<div id="partialContent">
</div>
</div>
</div>
<script>
function showBook() {
$('#partialContent').load("/Controllers/BooksController/BookDetail");
}
</script>
Book Detail Controller:
public IActionResult BookDetail(string barcodes)
{
var request = $"?barcodes={barcodes}";
var products = _httpTool.HttpGetAsync<List<Products>>($"{AppSettings.ApiUrl}/GetProducts{request}");
if(products.Result.Count != 0)
{
ViewBag.result = "Success";
var product = products.Result[0];
return PartialView("_BookDetailPartial", product);
}
else
{
ViewBag.result = "Failed";
return View("AddBook");
}
}
_BookDetailPartial:
<div>
<h4>PartialCame</h4>
<br />
<h5>#Model.Author</h5>
</div>
What is the problem here?
Thanks in advance!
onclick="showBook"
should be
onclick="showBook()"
And this path appears to be wrong: "/Controllers/BooksController/BookDetail" it should most likely be "/Books/BookDetail?barcodes=barcode"
I'm not sure what you mean about the partial view loading in another page. Could you give some more detail please?
Layout -> View -> Partial View
In the View:
<div class="col-md-8">
#{Html.RenderPartial("_komentari", commentlist);}
<div class="gap gap-small"></div>
<div class="box bg-gray">
<h3>#Res.commentwrite_title</h3>
#using (Ajax.BeginForm("postcomment", new { propertyid = Model.PublicID }, new AjaxOptions { UpdateTargetId = "commentsarea", HttpMethod = "Post", InsertionMode = InsertionMode.Replace }, null))
{
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label>#Res.commentwrite_content</label>
<textarea id="comment" name="comment" class="form-control" rows="6"></textarea>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" value='#Res.commentwrite_btn' />
</div>
</div>
</div>
}
</div>
</div>
In the Partial View:
<div id="commentsarea">
<ul class="booking-item-reviews list">
#if (Model != null)
{
foreach (Comment item in Model)
{
<li>
<div class="row">
<div class="col-md-2">
<div class="booking-item-review-person">
<a class="booking-item-review-person-avatar round" href="#">
<img src="/assets/img/70x70.png" alt="Image Alternative text" title="Bubbles" />
</a>
<p class="booking-item-review-person-name">
#if (item.UserId != null)
{
<a href='#Url.Action("details", "user", new { userid = item.User.PublicId })'>#item.User.Username</a>
}
else
{
Anonymous
}
</p>
</div>
</div>
<div class="col-md-10">
<div class="booking-item-review-content">
<p>
#item.Content
</p>
<p class="text-small mt20">#item.DateOnMarket</p>
<p class="booking-item-review-rate">
#using (Ajax.BeginForm("reportcomment", new { comment = item.PublicId }, new AjaxOptions { UpdateTargetId = "reportscount", HttpMethod = "Post", InsertionMode = InsertionMode.Replace }, null))
{
<a id="submit_link" href="#">Spam?</a>
<a class="fa fa-thumbs-o-down box-icon-inline round" href="#"></a>
}
<b id="reportscount" class="text-color">#item.CommentReports.Count</b>
</p>
</div>
</div>
</div>
</li>
}
}
</ul>
</div>
<script>
$(function () {
$('a#submit_link').click(function () {
$(this).closest("form").submit();
});
});
</script>
View
Both scripts for Ajax are always included in the Layout (I'm already using Ajax on other pages too). On the View page, when I add a new comment, it is added in the database and shows the updated list of comments via ajax. Everything works fine.
Partial View
But if I want to report the comment as spam, I have to click on the link inside the Partial View (#submit_link), and after reporting, inside the #reportscount part, I want to show the updated number of reports of that comment. The actionresults returns that number like Content(numberofreports.toString()). It works but I get the number in a blank page?
Thank you very much.
It's better if you don't. The main issue is that, for security reasons, <script> tags are ignored, when HTML is inserted into the DOM. Since the Ajax.* family of helpers work by inserting <script> tags in place, when you return the partial via AJAX, those will not be present. It's better if you only include the HTML contents of the form in the partial, and not the form itself.
I am pretty advanced in C# but a newcomer in the world of ASP.NET.
My HomeController.cs:
public ActionResult Index()
{
// tuple -> item1 = key string / item2 = assigned list
var configList = new List<Tuple<string, List<string>>>();
configList = fillItWithSomeData(..)
ViewBag.ConfigSettings = configList;
return View();
}
My Index.cshtml:
<div>
<div class="row">
#foreach (var elements in ViewBag.configSettings)
{
<div class="col-md-8 checkbox">
/*I NEED A BUTTON HERE*/
<label>
<input type="checkbox">#elements.Item1
</label>
</div>
foreach (var listElement in elements.Item2)
{
<div class="col-md-8 col-md-offset-1 checkbox">
<label>
<input type="checkbox">#listElement
</label>
</div>
}
}
</div>
</div>
Every key string in my list contains a list of strings. (look at var configList)
In my view I want to have a button for each key string which should be able to open or close the assigned list of the respective key string. I currently use ASP.NET-MVC. How can I program that? In C# or do I need to use JS for that? I really have no idea. Thanks in advance.
You can use bootstrap Accordion or bootstrap Collapsible panel.
below code using bootstrap Collapsible panel.
<div>
<div class="row">
#foreach (var elements in ViewBag.configSettings)
{
<div class="col-md-8 checkbox">
/*I NEED A BUTTON HERE*/
<label>
<input type="checkbox" data-toggle="collapse" data-target="##elements.Item1">#elements.Item1
</label>
</div>
foreach (var listElement in elements.Item2)
{
<div class="col-md-8 col-md-offset-1 checkbox collapse" id="#elements.Item1">
<label>
<input type="checkbox">#listElement
</label>
</div>
}
}
</div>
I have a modal window with angular-material tabs and a ui-bootstrap datepicker. When I open datepicker, the text field moves up, and I cannot access either the datepicker or the field.
Here's a demo in jsFiddle
Here's my code:
var app = angular.module('myApp', ['ui.bootstrap', 'ngAnimate', 'ngAria', 'ngMaterial'])
.controller('myController', function ($scope, $modal) {
$scope.showModal = function () {
var modalInstance;
modalInstance = $modal.open({
templateUrl: "addNew.html",
controller: 'myController2',
size: 'lg'
});
};
$scope.showModal();
})
.controller('myController2', function ($scope, $modal) {
$scope.datepickers = {
start: false
}
$scope.openDatepicker = function ($event, which) {
$event.preventDefault();
$event.stopPropagation();
$scope.datepickers[which] = true;
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
$scope.dateFormat = 'mediumDate';
});
<div ng-app="myApp">
<div ng-controller="myController">
<script type="text/ng-template" id="addNew.html">
<div class="modal-body">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Add</h3>
</div>
<div class="panel-body">
<md-tabs md-dynamic-height md-border-bottom>
<md-tab label="date">
<div class="form-horizontal">
<div class="row">
<div class="col-md-6">
<div class="row form-group">
<label for="dateStart" class="col-sm-2 col-md-4 control-label">
Date Start
</label>
<div class="col-sm-10 col-md-8">
<div class="input-group ui-datepicker">
<input type="text"
class="form-control"
name="dateStart"
id="dateStart"
datepicker-popup="{{dateFormat}}"
ng-model="campaign.dateStart"
is-open="datepickers.start"
datepicker-options="dateOptions"
ng-required="true"
ng-click="openDatepicker($event, 'start')"
close-text="Close"/>
<span class="input-group-addon" ng-click="openDatepicker($event, 'start')">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</md-tab>
<md-tab label="other tabs"></md-tab>
<md-tab label="other tabs"></md-tab>
<md-tab label="other tabs"></md-tab>
<md-tab label="other tabs"></md-tab>
</md-tabs>
</div>
</div>
</div>
</script>
</div>
</div>
I used a css trick to add the scroll bar in this fiddle, but it's not very neat. So I was wondering if there is a way to expand the tab height when the datepicker is opened or the datepicker is shown over a modal window like the select window opens.
You'll want to have the dropdown datepicker appear as part of the regular document flow, that way it will occupy space and the tab picker will automatically make room for it. It doesn't do that currently because it uses .dropdown-menu, to which Bootstrap adds position: absolute;
Just override like this:
.dropdown-menu[datepicker-popup-wrap] {
position: static;
}
There are some other stylistic things you can do, but that is the basic principle.
Demo in jsFiddle