Why opening bootstrap modal using wire:click and dispatch event Blocks Scrolling in admin menu - laravel

I have a problem when I use the following code for adding and displaying:
<a href="javascript:void(0)" data-toggle="modal" data-target="#modalYear">
<span class="sub-item">Add year</span>
</a>
<a href="javascript:void(0)" data-toggle="modal" data-target="#ListYear">
<span class="sub-item">Listyear</span>
</a>
Nothing gets blocked but the problem comes when I want to use the edit option the admin menu stops scrolling, this is where the problem starts and also when I use this :
<a href="javascript:void(0)" wire:click="ShowReportModal('add')">
span class="sub-item">Add Year</span>
</a>
the modal will show up but when I close it the admin menu stops scrolling.
After so many tries I figured out that the problem is using wire:click to call the modal for adding, editing and displaying.
this is my component:
public function ShowReportModal($action)
{
if($action == 'add')
{
$this->dispatchBrowserEvent('ModalYearVisible') ;
}
else{
$this->dispatchBrowserEvent('ModalListVisible') ;
}
}
Here is the admin menu code:
<li class="nav-item">
<a data-toggle="collapse" href="#annee">
<i class="far fa-calendar-alt"></i>
<p>Scholar year</p>
<span class="caret"></span>
</a>
<div class="collapse" id="annee">
<ul class="nav nav-collapse">
<li>
<a href="javascript:void(0)" wire:click="ShowReportModal('add')">
<span class="sub-item">Add year</span>
</a>
</a>
</li>
<li>
<a href="javascript:void(0)" wire:click="ShowReportModal('list')">
<span class="sub-item">Years List</span>
</a>
</li>
</ul>
</div>
</li>
Any help would be appreciated and also why is this happening?

Related

issue in conversion of bootstrap btn-group html code in php variable using anchor function

i am using codeigniter.i am trying to convert this bootstrap code into a php variable for HTML table class
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-default pull-right" role="menu">
<li>
<a href="#" onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/modal_take_payment/<?php echo $row['invoice_id'];?>');">
<i class="entypo-bookmarks"></i>
Take Payment </a>
</li>
<li class="divider"></li>
<!-- VIEWING LINK -->
<li>
<a href="#" onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/modal_view_invoice/<?php echo $row['invoice_id'];?>');">
<i class="entypo-credit-card"></i>
View Invoice </a>
</li>
<li class="divider"></li>
<!-- EDITING LINK -->
<li>
<a href="#" onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/modal_edit_invoice/<?php echo $row['invoice_id'];?>');">
<i class="entypo-pencil"></i>
Edit </a>
</li>
<li class="divider"></li>
<!-- DELETION LINK -->
<li>
<a href="#" onclick="confirm_modal('<?php echo base_url();?>index.php?admin/invoice/delete/<?php echo $row['invoice_id'];?>');">
<i class="entypo-trash"></i>
Delete </a>
</li>
</ul>
</div>
result of above HTML code
now i want to convert this complete html code into a php syntax so i can use it in HTML table class and code for this is as below-
[$edit_url =base_url().'index.php?modal/popup/modal_edit_invoice/'. $row\['invoice_id'\];
$url = base_url().'index.php?modal/popup/modal_take_payment/'. $row\['invoice_id'\];
$url_delete= base_url().'index.php?admin/invoice/delete/'. $row\['invoice_id'\];
$url_invoice= base_url().'index.php?modal/popup/modal_view_invoice/'. $row\['invoice_id'\];
$onclick_delete = array('onclick'=>"return confirm_modal('{$url_delete}')" , 'class'=>"btn-default btn-sm dropdown-toggle");
$onclick_edit = array('onclick'=>"return showAjaxModal('{$edit_url}')" , 'class'=>"btn btn-default btn-sm dropdown-toggle");
$onclick_take = array('onclick'=>"return showAjaxModal('{$url}')",'class'=>"btn btn-default btn-sm dropdown-toggle");
$onclick_invoice = array('onclick'=>"return showAjaxModal('{$url_invoice}')",'class'=>"btn btn-default btn-sm dropdown-toggle");
$links = anchor('#', 'Take Payment',$onclick_take);
$links .= anchor('#', 'edit',$onclick_edit);
$links .= anchor('#', 'Invoice',$onclick_invoice);
$links .= anchor('#', 'delete',$onclick_delete);
but this is not giving me the result as above html code. so can you please suggest me the changes in the code.
problem_II
and when i am using above code bootstrap model properties also not working as expected.the problem is Body is not auto scrolling to top when model is popup and for that reason model is not coming properly on my screen. although i didn't made any changes in body.modal-open.
please help me out. thanks in advance

Set class on Parent and Sub-Menu in Laravel Bade View

I want to set m-menu__item--open class on parent menu <li> and m-menu__item--active class on sub-menu item <li> in my Laravel bade based on current page. Below is the HTML extracted from the bade template.
<li class="m-menu__item m-menu__item--open" aria-haspopup="true" m-menu-submenu-toggle="hover">
<a href="javascript:;" class="m-menu__link m-menu__toggle">
<i class="m-menu__link-icon flaticon-layers"></i>
<span class="m-menu__link-text">FAQ</span>
<i class="m-menu__ver-arrow la la-angle-right"></i>
</a>
<div class="m-menu__submenu " m-hidden-height="840">
<span class="m-menu__arrow"></span>
<ul class="m-menu__subnav">
<li class="m-menu__item m-menu__item--active" aria-haspopup="true">
<a href="{{ url('/') }}/admin/faq/list/1" class="m-menu__link ">
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
<span></span>
</i>
<span class="m-menu__link-text">English</span>
</a>
</li>
<li class="m-menu__item m-menu__item" aria-haspopup="true">
<a href="{{ url('/') }}/admin/faq/list/2" class="m-menu__link ">
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
<span></span>
</i>
<span class="m-menu__link-text">Korean</span>
</a>
</li>
<li class="m-menu__item m-menu__item" aria-haspopup="true">
<a href="{{ url('/') }}/admin/faq/list/3" class="m-menu__link ">
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
<span></span>
</i>
<span class="m-menu__link-text">Chinese</span>
</a>
</li>
</ul>
</div>
</li>
as I understand, you want to change your menu classes by the current url..
laravel has is() method in Request class. You may want to use it.
class="{{Request::is('category/products') ? 'm-menu__item--active' : 'm-menu__item--open'}}"
if your current url base-url/category/products then you're gonna get the 'm-menu__item--active' class

VueJS get variable as text

I'm working on a Laravel project and i use VueJS for notifications system.
However, i'm a real noob in VueJS dev'. Consequently, i don't know how to print a variable as text.
Situation : System of notifications work and i would like to print the number of notifications in a bootsrap badge. So, i did this :
<i class="fa fa-bell-o" aria-hidden="true"></i> Notifications <span id='badge' class="badge badge-info">{{notifications.length}}</span> <span class="caret"></span>
With this code in my Notification.vue file :
<template>
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
<i class="fa fa-bell-o" aria-hidden="true"></i> Notifications <span id='badge' class="badge badge-info">{{notifications.length}}</span> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li style="text-align:center" v-for="notification in notifications">
<a href="#" v-on:click="MarkAsRead(notification)">
{{notification.data.idea.name}} a été validée !<br>
</a>
</li>
<li style="text-align: center" v-if="notifications.length==0">
Aucune notification !
</li>
</ul>
</li>
</template>
<script>
export default {
props: ['notifications'],
methods: {
MarkAsRead: function (notification) {
var data = {
id: notification.id
};
axios.post('/notification/read', data).then(response => {
window.location.href = "/manif/";
});
}
}
}
</script>
Finally i only see {{notifications.length}} write in the badge instead of a number...
Can you help me about this ?
Thank's
The raw mustache tags are shown because you've used v-pre directive in the parent element, which tells Vue to not compile the element and its children:
<a id="navbarDropdown" ... v-pre> <!-- Don't use v-pre here -->
...
<span ...>{{notifications.length}}</span>
</a>
Simply removing that directive should resolve the issue: demo

Laravel 4 base/master view

I've recently gotten some problems. There is an model from which I pull some data and things. There is a menu link that I want to be on every page I enter, so I've put it into the base/master view. But the problem is, I need to enter ->with blabla thing on every public function in every controller. How could I not do that? I mean is there anyway around it? I don't want to do that with thingy on every controller method/function. Here's my code:
#if ( Auth::guest() )
<li style="float: right;padding-right: 0">
<ul class="nav">
<li>
<a href="{{ URL::to('register') }}">
<i class="icon-black icon-plus">
</i>
<strong>
Register
</strong>
</a>
</li>
<li>
<a href="{{ URL::to('login') }}">
<i class="icon-black icon-lock">
</i>
<strong>
Log in
</strong>
</a>
</li>
</li>
</li>
</ul>
#else
<li class="divider-vertical">
</li>
<li style="float: right;padding-right: 0">
<div class="btn-group">
<div class="btn btn-primary">
<i class="icon-user">
</i>
{{ (Auth::user()->name) }}
</div>
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
<span class="icon-caret-down">
</span>
</a>
<ul class="dropdown-menu">
<li>
<a href="{{ URL::to('account/managment') }}">
<i class="icon-user">
</i>
Account Managment
</a>
</li>
<li>
<a href="{{ URL::to('account/managment/change_credentials') }}">
<i class="icon-lock">
</i>
Change Password
</a>
</li>
<li class="divider">
</li>
<li>
<a href="{{ URL::to('account/logout') }}">
<i class="icon-off">
</i>
Log out
</a>
</li>
</ul>
</div>
#endif
You can define a View Composer :
View::composer(array('your.first.view','your.second.view'), function($view)
{
$view->with('count', User::count());
});
Everytime you call your view, a user count will be bound to it automatically.
Edit:
About where to use it, it's up to you and it depends on your app, but you might use pp/start/global.php if you don't have a better place to put it. It just have to be executed before your those views.
#Antonio's answer is a good way to do this. You can also use View::share(); to accomplish this with a shorter code.
View::share(array(
'foo' => 'bar'
));

dropdown menu, Brootstrap, menu center, text left-sided

I am sure somebody has aleady posted such a question but I could not find a solution.
I am using Ruby on Rails, Brootstrap and I want to be my dropdown menu(whole) in the middle of the page, but the text (links like We, What we do and etc...) in the dropdown-menu should be left-sided.
How can I do it?
<div class="btn-toolbar">
<div class="btn-group">
<button id="action-btn" class="btn dropdown-toggle" data-toggle="dropdown">
About us
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="del">
<strong> We</strong>
</a>
</li>
<li>
<div class="mcol">
<ul class ="sub">
<div class ="subcolumns menuactivity">
What we do
</li>
Countries
</div>
</ul>
<li>
<a href="del">
<strong>References </strong>
</a>
</li>
</ul>
<div class="btn-group">
<button id="action-btn" class="btn dropdown-toggle" data-toggle="dropdown">
News & Events
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="del">
<strong>Calender</strong>
</a>
</li>
<ul class ="sub">
<div class ="subcolumns menuactivity">
<li>
News archive
</li>
</ul>
</div>
</ul>
</div>
If you're using bootstrap as it is by default you can try below
<a class="pull-left" href="details"> What we do </a>
I have updated with an example.
http://jsfiddle.net/acc8t/
I did this by using below css
.sub{margin-left:0px;}
I have founf as well another solution already.
Just to put in css the following code:
.dropdown-menu {
text-align: left;
}
.btn-toolbar{
text-align: center;
padding-bottom:40px;
}​

Resources