Problems with materialize call to js process - php

I'm working with one web app using Materialize, everything work fine till add search field. There are no error but button do nothing. In the same row, there are two buttons, first one work.
usuario.php:
<div class="container">
<div class="col s6 left">
Buscar:
<div class="input-field inline">
<input id="fCriterio" type="text" class="validate">
<label for="fCriterio">
</label>
</div>
<button class="btn-floating btn-small blue" onclick="buscarCrit()">
<i class="material-icons">search</i>
</button>
</div>
<div class="col s2 right">
<button class="btn modal-trigger blue" data-target="idModal1">
Nuevo
</button>
</div>
</div>
And js (user-functions.js) included is just a test:
function buscarCrit(){
M.toast({html: "Buscando", classes:'green'});
}
I copy another button who is working and doesn't work, no error, no nothing.

Ok I found the error, it was very simple but I did not see it, the call to the function has to have parentheses at the end of its name.
`
<a class="btn-floating btn-small green" data-toggle="modal" onclick="buscarCrit()">
<i class="material-icons">search</i>
</a>
</td>`
Thank's #imvain2 and #Zugor for your time and help!!

Try using a click event than inline onclick. Declare a click event listener for that button and call buscarCrit in there.
Example:
function buscarCrit(){
alert('Hello World!')
M.toast({html: "Buscando", classes:'green'});
}
window.addEventListener('load', () => {
document.getElementById('btn-foo').addEventListener('click', buscarCrit);
});
<div class="container">
<div class="col s6 left">
Buscar:
<div class="input-field inline">
<input id="fCriterio" type="text" class="validate">
<label for="fCriterio">
</label>
</div>
<button id="btn-foo" class="btn-floating btn-small blue">
<i class="material-icons">search</i>
</button>
</div>
<div class="col s2 right">
<button class="btn modal-trigger blue" data-target="idModal1">
Nuevo
</button>
</div>
</div>

Related

Show content for an specific item in Laravel

I have a list of Pipelines and their stages, I need tho show the stages of each pipelines when these are clicked. The thing is that I don't want to show them all, just the ones that are clicked...
I have this code on my project, the thing is that with this it shows all of the stages of all of the pipelines, and I need just show the stages of the clicked pipeline. How can I dynamically link each other
<div class="panel-body" id="body-pipelines">
#foreach($pipelines as $key => $pipeline)
<div class="pipelines">
<div class="col-md-3 row">
<div class="col-md-12 col-sm-12 col-xs-12 p-t-10 p-b-10" id="pipelines-sidebar">
<i class="fas fa-lg fa-fw m-r-10 fa-{{$pipeline->icon}}"></i>
<span>{{$pipeline->name}}</span>
</div>
</div>
<div class="col-md-8">
<div class="row float-right">
<button class="btn"><i class="fas fa-plus-circle" id="agregar"></i></button>
</div>
<div class="sortable box row">
#foreach ($pipeline->stages as $stage)
<div class="stages txt username m-b-10" id="stages-{{$stage->id}}" style="background: {{$stage->color}}" onclick="javascript:;" data-type="text">{{$stage->name}} <div class="delete-stage float-right"><button class="btn btn-danger"><i class="fas fa-trash" id="eliminar"></i></button></div></div>
#endforeach
</div>
</div>
</div>
#endforeach
</div>

Yii2 tabular form radio button single selection issue

I created a tabular form in yii2 with question and multiple options. Getting issue with radio button due to different name. Not able to select single correct option.
<input type="radio" id="tbloptions-0-correct" name="Tbloptions[0][correct]" value="1" checked="" aria-invalid="false">
<input type="radio" id="tbloptions-1-correct" name="Tbloptions[1][correct]" value="1" checked="">
Yii2 create action code
<?php foreach ($modelOptions as $i => $modelOption): ?>
<div class="item panel panel-default"><!-- widgetBody -->
<div class="panel-heading">
<h3 class="panel-title pull-left">Option</h3>
<div class="pull-right">
<button type="button" class="add-item btn btn-success btn-xs"><i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button>
</div>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-1">
<?= $form->field($modelOption, "[{$i}]correct")->radio(['label'=>false]) ?>
</div>
<div class="col-md-6">
<?= $form->field($modelOption, "[{$i}]options")->textArea()->label(false) ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
Snapshot given below -
$( "#container" ).on( "click", ".list-cell__radio", function() {
$('input[type=radio]').each(function( index ) {
$( this ).prop("checked", false);
});
$(this ).find("input[type=radio]").prop("checked", true);
});

showing data in modal in laravel

I'm using Laravel and I'm trying to delete or update the services on my platform
I'm using confirmation modal for that..
but when I delete or or update or show content in the modal it always works on the first row only...
that's the code
#foreach ($services as $service)
<div class="card-content">
<div class="row">
<div class="col l4">
<div class="row">
<div class="col s12">
<span>
<a class="btn-floating btn-large modal-trigger tooltipped waves-effect waves-light red hoverable"
data-position="left"
data-tooltip="Supprimer ce service"
data-text-color="grey-text"
href="#modal1">
<i class="material-icons">delete</i>
</a>
</span>
<span>
<a class="btn-floating btn-large modal-trigger tooltipped waves-effect waves-light green"
data-position="right"
data-tooltip="Modifier ce service"
data-delay="20"
href="#modal2">
<i class="material-icons" href="#modal2">update</i>
</a>
</span>
</div>
</div>
<div id="modal1" class="modal">
<div class="modal-content">
<div class="row">
<div class="col s6">
<p>Voulez vous vraiment supprimer ce service ?</p>
</div>
<div class="col s6">
<form action="/Services/{{$service->id}}" method="POST">
{{ csrf_field() }}
#method('DELETE')
<span>
<input type="submit" class="btn purple hoverable waves effect" value="supprimer">
</span>
<span>
Non
</span>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
Invoke modal via jquery like
$('#myModal').modal('show');
$('#myModal').modal('hide');
In Loop Anchor
<span>
<a class="btn-floating btn-large modal-trigger tooltipped waves-effect waves-light green modalclick"
data-position="right"
data-tooltip="Modifier ce service"
data-delay="20"
data-id="<?php echo $service->id; ?>"
href="javascript:void(0)"
>
<i class="material-icons" href="#modal2>update</i>
</a>
</span>
$(".modalclick").click(function(){
var current_id = $(this).attr("data-id");
//use jquery below to change modal form action with id
$('#myModal').modal('show');
});
Define modal popup for each record if you in loop if you dont want to use jquery that get and service id and pass into modal form.
<?php $a = 1; ?>
#foreach ($services as $service)
<div class="card-content">
<div class="row">
<div class="col l4">
<div class="row">
<div class="col s12">
<span> <a class="btn-floating btn-large modal-trigger tooltipped waves-effect waves-light red hoverable" data-position="left" data-tooltip="Supprimer ce service" data-text-color="grey-text" href="#modal{{$a}}"><i class="material-icons">delete</i></a></span>
<span> <a class="btn-floating btn-large modal-trigger tooltipped waves-effect waves-light green" data-position="right" data-tooltip="Modifier ce service" data-delay="20" href="#modal2"><i class="material-icons" href="#modal2">update</i></a></span>
</div>
</div>
<div id="modal{{$a}}" class="modal">
<div class="modal-content">
<div class="row">
<div class="col s6">
<p>Voulez vous vraiment supprimer ce service ?</p>
</div>
<div class="col s6">
<form action="/Services/{{$service->id}}" method="POST">
{{ csrf_field() }}
#method('DELETE')
<span>
<input type="submit" class="btn purple hoverable waves effect" value="supprimer">
</span>
<span>
Non
</span>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php $a++; ?>
#endforeach
See if it is work for you.

How to get mutilple file upload images using flow js with angular in php server side

Here i add my code and set codeigniter url like 'apis/service/manish_sharma' , but i not getting any files array in my api.so please help me
<div
flow-init="{target:'apis/service/manish_sharma'}"
flow-files-submitted="$flow.upload()"
flow-file-added="!!{png:1,gif:1,jpg:1,jpeg:1}[$file.getExtension()]"
>
<div class="drop" flow-drop ng-class="dropClass">
<span class="btn btn-default" flow-btn>Upload Image</span>
</div>
<br/>
<div>
<div ng-repeat="file in $flow.files" class="gallery-box">
<span class="title">{{file.name}}</span>
<div class="thumbnail" ng-show="$flow.files.length">
<img flow-img="file" />
</div>
<div class="progress progress-striped" ng-class="{active: file.isUploading()}">
<div class="progress-bar" role="progressbar"
aria-valuenow="{{file.progress() * 100}}"
aria-valuemin="0"
aria-valuemax="100"
ng-style="{width: (file.progress() * 100) + '%'}">
<span class="sr-only">{{file.progress()}}% Complete</span>
</div>
</div>
<div class="btn-group">
<a class="btn btn-xs btn-danger" ng-click="file.cancel()">
Remove
</a>
</div>
</div>
<div class="clear"></div>
</div>
</div>
Hi frd , finally i found the solution
Step 1 : Add html code in your template html file
<div flow-init flow-name="uploader.flow"
flow-file-added="!!{png:1,gif:1,jpg:1,jpeg:1}[$file.getExtension()]">
<div class="drop" flow-drop ng-class="dropClass">
<!--<span class="btn btn-default" flow-btn>Upload Image</span>-->
<input type="file" flow-btn />
</div>
<br/>
<div>
<div ng-repeat="file in $flow.files" class="gallery-box">
<span class="title">{{file.name}}</span>
<div class="thumbnail" ng-show="$flow.files.length">
<img flow-img="file" />
</div>
<div class="progress progress-striped" ng-class="{active: file.isUploading()}">
<div class="progress-bar" role="progressbar"
aria-valuenow="{{file.progress() * 100}}"
aria-valuemin="0"
aria-valuemax="100"
ng-style="{width: (file.progress() * 100) + '%'}">
<span class="sr-only">{{file.progress()}}% Complete</span>
</div>
</div>
<div class="btn-group">
<a class="btn btn-xs btn-danger" ng-click="file.cancel()">
Remove
</a>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<button class="btn-primary btn" type="button" ng-click="upload_fun()">Add Service</button>
Step 2 : declare variable in angular controller
$scope.uploader={};
$scope.upload_fun = function()
{
$scope.uploader.flow.opts.testChunks=false;
$scope.uploader.flow.opts.target='apis/service/manish_sharma; /* your server side api path*/
$scope.uploader.flow.upload();
}
Step 3: whatever you declare your server side path
Codeigniter (PHP framework)
controller name: service
function name : manish_sharma
function manish_sharma()
{
$target_file = '/upload' . basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'],$target_file);
echo "<pre>";
print_r($_FILES);
}

How to change the style properties in a div which is written inline style?

I have written a code for modifying the inline style for a div. The code is shown below :
<div class="padd col-xs-12 col-sm-12 col-md-12 pern alert" id="bloc" style="display:none;">
<div class="pad col-xs-12 col-md-6">
<h4>dfdfdffddf</h4>
</div>
<div class="pad col-md-5">
<span class="next-step"><button class="ret_but butt label label-primary" id="equipment" name="equipment" type="button">Select Equipment</button></span>
<div class="status">
<b>Status</b>
<i class="open" id="open">Open</i>
</div>
</div>
<div class="pad col-xs-12 col-md-1">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button"> <i class="fa fa-trash-o" aria-hidden="true"></i> </button>
</div>
</div>
I want to change the style for the div with id = bloc as display: block. I have written a jquery code for it, but it is not working.
jquery :
$("#senddata").click(function() {
$(".padd").css('style','display:block;');
});
senddata is the id of a button inside a form.When I am clicking that button, the inline style of particular div should change to display:block. But it is not changing the style. Can anyone help me on this ?
style is not a valid style attribute. you need to change display
$(".padd").css('display','block');
It does not matter if the style is written in the style attribute or in a css file when you want to change it with jquery
your JQ is not correct . you could use the show() method instead
show()
$("#senddata").click(function() {
$(".padd").show()
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="senddata">
senddata
</button>
<div class="padd col-xs-12 col-sm-12 col-md-12 pern alert" id="bloc" style="display:none;">
<div class="pad col-xs-12 col-md-6">
<h4>dfdfdffddf</h4>
</div>
<div class="pad col-md-5">
<span class="next-step"><button class="ret_but butt label label-primary" id="equipment" name="equipment" type="button">Select Equipment</button></span>
<div class="status">
<b>Status</b>
<i class="open" id="open">Open</i>
</div>
</div>
<div class="pad col-xs-12 col-md-1">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button"> <i class="fa fa-trash-o" aria-hidden="true"></i> </button>
</div>
</div>
If you have used display:none on inline style you have to use the show() and hide() methods in jQuery.
$("#senddata").click(function() {
$(".padd").show()
});

Categories