Im displaying a treeview data and everything works perfecly.
But when i add the fourth raw, Laravel crash.
I want to post my code but i don't even know which one and where that came from..
view :
<div class="list-group">
<div class="col-md-12">
<div class="col-md-2">Departement</div>
<div class=" float-right">
<button class=" btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1" >
<span class="glyphicon glyphicon-eye-open"></span></button>
<button type="submit" class="btn btn-warning " data-toggle="modal" data-target="#exampleModalposition"><span class="glyphicon glyphicon-plus-sign"></span></button> </div>
</div>
<div class="list-group-item" name="state">
#foreach($treeViewPosition as $departement)
<div class=" collapse multi-collapse collapse in " id="8" >
<div class="col-md-2"> {{ $departement->departement_name}}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $departement->id}}8" aria-expanded="false" aria-controls="{{ $departement->id}}8">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
<div class="list-group">
#if(count($departement->position))
#include('treeposition2',['position'=>$departement->position])
#endif
</div>
#endforeach
</div>
</div>
</div>
Related
I want to open a model for edit item. I have added wire:click on a div but that only works for the first item of foreach.
Livewire Method
public function selectMealPlan($mealId)
{
$this->dispatchBrowserEvent('openEditMealModal');
}
View file
#foreach ($meal_plans as $meal)
<div class="meals-plan-item">
<div class="meals-plan-item-type">
<div class="meals-plan-item-label" wire:click="test">MEAL TYPE:</div>
<div class="meals-plan-item-value">{{ $meal->meal_type }}</div>
</div>
<div class="meals-plan-item-names">
<div class="meals-plan-item-label">MEAL NAMES:</div>
<div class="meals-plan-item-value">{{ $meal->getMealItems() }}</div>
</div>
<div class="meals-plan-item-actions">
<div class="action-button edit" wire:click="selectMealPlan({{ $meal->id }})">
<i class="fas fa-pencil"></i>
</div>
<div class="action-button delete" data-toggle="modal" data-target="#deletePlan{{ $meal->id }}">
<i class="fas fa-trash"></i>
</div>
</div>
</div>
#endforeach
<script>
window.addEventListener('openEditMealModal', function() {
alert('hello');
})
</script>
The component should have only one root element, a div for example:
<div class="meals-plan-item">
#foreach ($meal_plans as $meal)
<div class="meals-plan-item-type">
<div class="meals-plan-item-label" wire:click="test">MEAL TYPE:</div>
<div class="meals-plan-item-value">{{ $meal->meal_type }}</div>
</div>
<div class="meals-plan-item-names">
<div class="meals-plan-item-label">MEAL NAMES:</div>
<div class="meals-plan-item-value">{{ $meal->getMealItems() }}</div>
</div>
<div class="meals-plan-item-actions">
<div class="action-button edit" wire:click="selectMealPlan({{ $meal->id }})">
<i class="fas fa-pencil"></i>
</div>
<div class="action-button delete" data-toggle="modal" data-target="#deletePlan{{ $meal->id }}">
<i class="fas fa-trash"></i>
</div>
</div>
#endforeach
</div>
I'm using ace-admin template (http://ace.jeka.by/) for my CI3 project. I want to populate a modal form from my view. it's working if i put code of modal on the same view, exemple :
<a href="#modal-table" role="button" class="green" data-toggle="modal">
<button class="btn btn-sm btn-default" id="myBtn">
<i class="ace-icon fa fa-plus align-top"></i>
Modal
</button>
</a>
<div id="modal-table" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header no-padding">
Results for "Latest Registered Domains
</div>
<div class="modal-body no-padding">
azerty
</div>
<div class="modal-footer no-margin-top">
<button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
<i class="ace-icon fa fa-times"></i>
Closee
</button>
</div>
</div>
</div>
</div>
But if i change href to send it to controller like this :
<a href="<?php echo base_url();?>ctl/add/" role="button" class="green" data-toggle="modal">
<button class="btn btn-sm btn-success" id="myBtn">
<i class="ace-icon fa fa-plus align-top"></i>
New
</button>
</a>
and on controller :
$this->theme_view = 'modal';
$this->render('parametres/utilisateurs/_new', $data);
the render function :
if (isset($this->theme_view)) {
$template = 'modal';
} else {
$template = 'master_view';
}
$name = 'contents';
$this->load->view('layouts/'.$template, $this->template_data);
And the modal layouts :
<div id="modal-table" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header no-padding">
Results for "Latest Registered Domains
</div>
<div class="modal-body no-padding">
<?=$contents;?>
</div>
<div class="modal-footer no-margin-top">
<button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
<i class="ace-icon fa fa-times"></i>
Closee
</button>
</div>
</div>
</div>
</div>
the view appear not like a modal form but in new page.
Any idea for this ?
I am currently learning ajax and have some problems with it. Whenever I reload the page I get over the data attributes of the modal no more data. Do I give the data wrong to the modal? Or do I have to reload something else?
The second problem is, the data in the modal or the input fields are displayed to me, but when I pass them to the controller and save there are no data available.
View
#foreach ($todolistprivate as $list)
<div id="todo-list-{{$list->id}}" class="panel panel-default panel-primary margin-bottom-0">
<div class="panel-heading panel-pointer">
<span class="elipsis"><!-- panel title -->
<strong>{{ $list->title }}</strong> <span class="label label-info white">0</span>
</span>
<ul class="options pull-right relative list-unstyled hover-visible">
<li><a data-toggle="modal" data-target=".task-modal" class="btn btn-success btn-xs white hover-hidden">
<i class="fa fa-plus"></i> Erstellen
</a>
</li>
<li><a data-toggle="modal" data-target=".todolist-update-modal" data-id="{{ $list->id }}" data-title="{{ $list->title }}" data-description="{{ $list->description }}" class="btn btn-info btn-xs white hover-hidden">
<i class="fa fa-edit"></i> Bearbeiten
</a>
</li>
<li><a data-toggle="modal" data-target=".todolist-destroy-modal" data-id="{{ $list->id }}" data-title="{{ $list->title }}" data-description="{{ $list->description }}" class="btn btn-danger btn-xs white hover-hidden">
<i class="fa fa-times"></i> Löschen
</a>
</li>
<li></li>
</ul>
</div>
<div class="panel-body">
<div class="slimscroll min-height-30 max-height-100">
{{ $list->description }}
</div>
</div>
</div>
#endforeach
Modal
<div class="modal fade todolist-update-modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Bearbeite diese Liste</h4>
</div>
<div class="modal-body">
<form>
<input type="hidden" name="id" id="id" value="">
<div class="form-group">
<label for="" class="control-label">Titelname</label>
<div class="fancy-form">
<i class="fa fa-header"></i>
<input id="title" name="title" type="text" class="form-control input-lg" placeholder="Titel">
</div>
</div>
<div class="form-group">
<label for="" class="control-label">Beschreibung</label>
<div class="fancy-form">
<textarea id="description" name="description" rows="2" class="form-control" placeholder="Beschreibe deine Aufgabe"></textarea>
<i class="fa fa-comments"><!-- icon --></i>
</div>
</div>
<div class="form-group">
<label for="" class="control-label">Privatsphäre</label>
<div class="fancy-form fancy-form-select">
<select id="privacy" name="privacy" class="form-control">
<option value="0">Öffentlich</option>
<option value="1">Privat</option>
</select>
<i class="fancy-arrow"></i>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" id="update-todo-list">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Function:
$('.todolist-update-modal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var title = button.data('title');
var description = button.data('description');
var id = button.data('id');
var modal = $(this);
modal.find('.modal-body input').val(title);
modal.find('.modal-body textarea').val(description);
modal.find('.modal-body #id').val(id);
});
$(document).on('click','#update-todo-list', function(e) {
e.preventDefault();
var _token = $("input[name='_token']").val();
var title = $("input[name='title']").val();
var description = $("textarea[name='description']").val();
var privacy = $("select[name='privacy']").val();
var id = $("input[name='id']").val();
$.ajax({
url:'/admin/tasks/update/'+id,
type: 'Put',
data: {_token:_token, title:title, description:description, privacy:privacy, id:id, _method:'put'},
dataType: 'json',
success: function (data) {
if (data.error) {
_toastr((data.error),"top-full-width","error",false);
console.log(data);
}
else{
$('.todolist-update-modal').modal('hide');
$("#wrapper").load(location.href+" #wrapper>*","");
_toastr((data),"top-full-width","success",false);
console.log(data);
}
}
});
});
This code need to display all "subcategory" for each "subcategories"
But the view result is the first subcategory only.
Where i missed please ?
View 1 :
#foreach($treeView as $category)
<div class="collapse multi-collapse collapse in " id="8" >
<div class="col-md-2"> {{ $category->account_name}}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $category->id}}8" aria-expanded="false" aria-controls="{{ $category->id}}8" #click="getSubaccount(); getNumberrawaccount();">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
<br>
<div class="list-group">
#if(count($category->subcategories))
#include('tree2',['subcategories'=>$category->subcategories])
#endif
</div>
#endforeach
View 2 : tree2
<div class='list-group'>
<br>
#foreach($subcategories as $subcategory)
<div class="list-group col-md-12">
<div class="collapse multi-collapse" id="{{ $category->id}}8" >
<div class="col-md-4"> {{ $subcategory->subaccount_name }}</div>
<div class=" float-right"><button class="btn btn-success" data-toggle="collapse" data-target="#{{ $subcategory->id}}" aria-expanded="false" aria-controls="collapseExample2">
<span class="glyphicon glyphicon-eye-open"></span></button></div>
</div>
</div>
#endforeach
</div>
Thank you
Robot framework doesn't identify the element by xpath.
Following is the code
<div id="sticky-actions-sticky-wrapper" class="sticky-wrapper" style="height: 100px;"><section class="content-header" id="sticky-actions" style="">
<h1>Curriculum</h1>
<div class="breadcrumb save-message hidden">
<label class="text-success">
<i class="flaticon flaticon-circle-check"></i>
Saved <span>a few seconds ago</span>
</label>
</div>
<div class="row p-t-15">
<div class="col-xs-12">
<button type="button" class="btn btn-primary add-task-btn" disabled="">Create New Task</button>
<div class="btn-group m-r-15">
<button type="button" class="btn btn-primary dropdown-toggle add-statement-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="">
Create <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a tabindex="0" class="add-curriculum-btn">Curriculum</a></li>
<li><a tabindex="0" class="add-learning-area-btn hidden">Learning Area</a></li>
<li><a tabindex="0" class="add-topic-btn hidden">Topic</a></li>
<li><a tabindex="0" class="add-outcome-btn hidden">Outcome</a></li>
</ul>
</div>
<button type="button" class="btn btn-circle btn-xs blue link-statements-btn" disabled="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Link selected statements">
<i class="fa fa-link"></i>
</button>
</div>
</div>
</section></div>
Xpath I used to for find "Create" button:
xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
xpath=//*[#id="sticky-actions"]/div[2]/div/div/button[.//text() = 'Create']
Robot Framework step:
click element xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button
Error:-
ValueError: Element locator 'xpath=//*[#id="sticky-actions-sticky-wrapper"]/div[2]/div/div/button' did not match any elements.
According to your XML, there is a section element inside the first div which you didn't include in your XPath. It should work if you add it:
//*[#id="sticky-actions-sticky-wrapper"]/section/div[2]/div/div/button
or
//*[#id="sticky-actions"]/div[2]/section/div/div/button[.//text() = 'Create']