This is my first time using react and I am sure that code given is probably not using react's best practices but I am just playing around with it to understand it for now, my problem is that I am trying to access the divs and paragraphs inside the modal but document querySelector returns null. Any ideas? Thanks
moreInfo(movie) {
const movieModalImg = document.querySelector(".movieModalImg");
const movieModalTitle = document.querySelector(".movieModalTitle");
const movieModalRunTimeNum = document.querySelector(
".movieModalRunTimeNum"
);
}
render() {
return (
<div>
<div id="modal">
<Modal
isOpen={this.state.setIsOpen}
onRequestClose={this.closeModal.bind(this)}
contentLabel="Example Modal"
>
<a className="closeModalBtn" onClick={this.closeModal} href={"#"}>
×
</a>
<div className="modal-wrapper">
<div>
<img src={moviePoster} className="movieModalImg" alt=""></img>
</div>
<p className="movieModalTitle"></p>
<div className="movieModalRunTime">
<h4>Runtime:</h4>
<p className="movieModalRunTimeNum"></p>
<p>Minutes</p>
</div>
<div className="movieModalProductionCountry">
<h4>Production Countries:</h4>
<p className="movieModalProductionCountries"></p>
</div>
<div className="movieModalVoteCount">
<h4>Vote Count:</h4>
<p className="movieModalVoteCountNum"></p>
</div>
<div className="movieModalRevenew">
<h4>Revenew:</h4>
<p className="movieModalRevenewNum"></p>
<p>$</p>
</div>
<div className="movieModalBudget">
<h4>Budget:</h4>
<p className="movieModalBudgetNum"></p>
<p>$</p>
</div>
</div>
</Modal>
</div>
<a
href="#"
className="movieCoverMoreInfo"
onClick={this.moreInfo.bind(this)}
>
<img className="moreInfoIcon" src={info} alt=""></img>
More Info
</a>
</div>
);
}
Related
I m trying to get product listing specific detail, while I click on the item from the listing page.
I used the react-router-dom navLink approach but failed. kindly guide how can I achieve with or without react-router. "listing to detail" how can I send the whole specific props from listing to detail components
product-listing.js component
<section className='product-listing-sec'>
<div className='container p-0'>
<div className='row'>
<div className='col-12'>
<h1>Category name</h1>
</div>
{/* product card list */}
{/* <ProductCard /> */}
{
data.products.map(prod=>{
return(
<div className='col-12 col-md-6 col-lg-4 col-xl-4' key={prod.title}>
<div className={`product-card ${prod.itemQuantity === 0 ? 'out-stock': ''}`}>
<Link to={{ pathname: `/product-discription`, state:{data:prod.title} }} className='img-wrap'>
<h5>Out of stock</h5>
<img src={prod.image} alt='product image' className='img-fluid' />
<div className='cartbtn'>
<img src={Cartlg} alt='cart' />
</div>
</Link>
<div className='card-detail'>
<p className='title'> {prod.title} </p>
<p className='price'>$ {prod.price} </p>
</div>
</div>
</div>
)
})
}
</div>
</div>
</section>
Product-detail.js page
export const ProductDiscription = (props)=> {
const { data } = props.location
console.log("data :"+ data)
return (<> <div> {data} </div> </>)
}
When I show a popup, the circle used for decoration show up, I don't know how solve that,
Here's the fiddle :
some code
https://jsfiddle.net/MagikMike/pctb9e0n/
Thanks
Give your circles IDs, in this case I added an ID circle0 and circle1 to both circles -
<div class="overlay" id="popup1"><div class="popup" id="popup"></div></div>
<div class="userMonitoringTarget">
<div class="circle1" id="circle0">
<div class="circle2">
<div class="circle3">
</div>
</div>
<div class="rectangle"></div>
</div>
<span class="dot"></span>
<div class="userMonitoring">
<div>
<span>
Date : 00/00/0000
</span>
<div>
<span>
LOREM IPSUM
</span>
</div>
</div>
<div class="userMonitoringAttachement">
<img src="/image/icon/icn-plus.svg" alt="+"
onclick="show_popup(' . $user->getNum() . ',' . $monitorings->id[$i] . ');return false;">
</div>
</div>
</div>
<div class="userMonitoringTarget">
<div id="circle1" class="circle1">
<div class="circle2">
<div class="circle3">
</div>
</div>
<div class="rectangle"></div>
</div>
<span class="dot"></span>
<div class="userMonitoring">
<div>
<span>
Date : 00/00/0000
</span>
<div>
<span>
LOREM IPSUM
</span>
</div>
</div>
<div class="userMonitoringAttachement">
<img src="/image/icon/icn-plus.svg" alt="+"
onclick="show_popup(' . $user->getNum() . ',' . $monitorings->id[$i] . ');return false;">
</div>
</div>
</div>
In your JS, your circles still showed because you didn't target them and set the visibility to hidden; now that we have IDs associated with the two circles you can properly get and set the visibility when the pop up is shown.
function hide_popup()
{
setTimeout(function()
{
document.getElementById('popup1').style.visibility = "hidden";
document.getElementById('popup1').style.opacity = 0;
document.getElementById('popup').innerHTML = "";
}, 100);
}
function show_popup( user, monitoring )
{
document.getElementById('circle0').style.visibility = "hidden";
document.getElementById('circle1').style.visibility = "hidden";
document.getElementById('popup1').style.visibility = "visible";
document.getElementById('popup1').style.opacity = 1;
}
You need to add a z-index for your popup wrapper like so.
#popup1 {
z-index: 999;
}
Here is my messageboard project, I don't know why the different will influence my css layout...
I just test english,chinese,thai they both work great, but only japanese will destroy my css style..
I use en_US,ja_JP,zh_TW,th_TH php file to change language
When use English
When use japanese
<li class="board_list">
<div class="board_img">
<img class="board_icon" src="./static/icon/board_icon.svg" alt="board icon">
</div>
<div class="board_text">
<div class="board_title">
<span>
<a href="./board.php?board_id=1">
<span>This was just test the title length of board name</span>
</a>
</span>
</div>
<div class="board_info">
<p class="p1">投稿:26</p>
</div>
</div>
<div class="board_latest">
<div class="board_latest_title">
<span>最新の投稿 :</span>
This was just test the title length of board name
</div>
<div class="board_latest_info">
<a href="./member.php?user=1" title="carry0987">
<span>carry0987,</span>
</a>
<span>2018-04-28</span>
</div>
</div>
</li>
<li class="board_list">
<div class="board_img">
<img class="board_icon" src="./static/icon/board_icon.svg" alt="board icon">
</div>
<div class="board_text">
<div class="board_title">
<span>
<a href="./board.php?board_id=2">
<span>Default</span>
</a>
</span>
</div>
<div class="board_info">
<p class="p1">投稿:6</p>
</div>
</div>
<div class="board_latest">
<div class="board_latest_title">
<span>最新の投稿 :</span>
This was just test the title length of board name
</div>
<div class="board_latest_info">
<a href="./member.php?user=2" title="carry0987y">
<span>carry0987y,</span>
</a>
<span>2018-04-28</span>
</div>
</div>
</li>
And this is my css code
.board_list {
border-width: 1px;
border-style: solid;
border-color: #E9E9E9;
}
You should add new div inside .board_list this class and add css property clear:both;
Something like this :
Also read this article : https://www.w3schools.com/cssref/pr_class_clear.asp
My problem is handlebars don't operate Json data output. I don't understand this problem. How can i handle it???
This is my JSON data
{
"boardInfo":
[
{"no":1,"title":"히히","url":null,"writerNick":"cheolhan","contents":"하하","createdDate":"2016-10-24","createdDate2":"2016-10-24","like":0,"viewCount":19,"email":null,"userNo":"1","categoryNo":2,"category":"스포츠","linkTitle":null,"linkURL":null,"linkDetailUrl":null,"linkImage":null,"linkDesc":null,"userProfilePath":null},
{"no":2,"title":"히히","url":null,"writerNick":"cheolhan","contents":"하하","createdDate":"2016-10-24","createdDate2":"2016-10-24","like":0,"viewCount":15,"email":null,"userNo":"1","categoryNo":2,"category":"스포츠","linkTitle":null,"linkURL":null,"linkDetailUrl":null,"linkImage":null,"linkDesc":null,"userProfilePath":null},
{"no":3,"title":"후후","url":null,"writerNick":"cheolhan","contents":"후후","createdDate":"2016-10-24","createdDate2":"2016-10-24","like":0,"viewCount":276,"email":null,"userNo":"1","categoryNo":2,"category":"스포츠","linkTitle":null,"linkURL":null,"linkDetailUrl":null,"linkImage":null,"linkDesc":null,"userProfilePath":null}
]
}
This is script code
var source = $('#liTemplateText').html();
var template = Handlebars.compile(source);
var data = result.data.boardInfo
data.stringify = JSON.stringify(data);
console.log(data)
var boards = template(data);
$("#post_wrapper").append(boards);
{{#each data}}
<li id="each_post_wrap">
<div id="each_post">
<div id="user_Nick">
<img class="user_Nonepht userInfoLink" src="/TeamProject/upload/{{userProfilePath}}" alt="userImg" data-userNo="{{userNo}}" data-userNick="{{writerNick}}">
<span class="userInfoLink" data-userNo="{{userNo}}" data-userNick="{{writerNick}}">{{writerNick}}</span>
</div>
<div class="post_photoWrap titleLink" data-no="{{no}}" data-userNo="{{userNo}}">
<a href="#">
<img src="{{linkImage}}" alt="Image File">
</a>
</div>
<a class="post_contsWrap">
<span class="each_post_title titleLink" data-no="{{no}}" data-userNo="{{userNo}}">{{title}}</span>
<span class="each_post_contents titleLink" data-no="{{no}}" data-userNo="{{userNo}}"><p>{{{contents}}}</p></span>
</a>
<div class="post_ctgWrap">
<span class="categoryLink" data-ctgNo="{{categoryNo}}">{{category}}</span>
</div>
<div class="post_BtnWrap">
<div class="post_leftBtn">
<img class="viewCount" src="/TeamProject/mainpage/mainpage_images/viewCount.png" alt="view">
<span>{{viewCount}}</span>
</div>
<div class="post_rightBtn">
<img class="like_Onclick" src="/TeamProject/mainpage/mainpage_images/likeOnClick.png" alt="like">
<span>{{like}}</span>
</div>
<div>
</div>
</li>
{{/each}}
This is HTML code
<div id="tabs" class="all_post_wrap">
<ul id="post_wrapper" class="tabs-1-contents">
</ul>
</div>
Any help much appreciated.
I have a json inside a ng-init where I have some data and I want to grab these data and paint into a template and I compiled with my directive and I don't have idea what I'm doing wrong. I can not paint json data into the template
example:
<li ng-init="product= {"brand":"Nike", "price":"30€", "mainImage":"images/images.jpg"}>
<div class="content-product>
<div class="product">
<p>Nike </p>
<img src="image.jpg" alt="">
<p>30€ </p>
</div>
</div>
</li>
This li is inside a loop in ruby.
Template where I want to paint the data and compile this template when I click on a button that is inside the li:
<script type="text/ng-template" id="quickpreview.html">
<div class="content-preview">
<div class="content-preview-inner">
<span class="full-preview"></span>
<span class="close-preview"></span>
<div class="block block-left left">
<div class="content-tabs">
<dl class="tabs vertical" data-tab>
<dd class="active">Tab 1
</dd>
<dd>Tab 2
</dd>
<dd>Tab 3
</dd>
<dd>Tab 4
</dd>
<dd>Tab 5
</dd>
</dl>
<div class="tabs-content vertical">
<div class="content active" id="panel1">
<div class="content-img">
<div class="main-img">
<img ng-src="{{product.mainImage}}" alt="">
</div>
<div class="thumbnails">
<a class="th" role="button" aria-label="Thumbnail" href="">
<img aria-hidden=true src="" />
</a>
</div>
</div>
</div>
<div class="content" id="panel2">
<p>This is the second panel of the basic tab example. This is the second panel of the basic tab example.</p>
</div>
<div class="content" id="panel3">
<p>This is the third panel of the basic tab example. This is the third panel of the basic tab example.</p>
</div>
<div class="content" id="panel4">
<p>This is the fourth panel of the basic tab example. This is the fourth panel of the basic tab example.</p>
</div>
<div class="content" id="panel5">
<p>This is the fifth panel of the basic tab example. This is the fourth panel of the basic tab example.</p>
</div>
</div>
</div>
</div>
<div class="block block-right right">
<div class="content-details">
<div class="details">
<h3 class="title-product">{{product.brand}}</h3>
<h2 class="short-desc">{{product.shortname}}</h2>
<div class="block-price">
</div>
</div>
</div>
</div>
</div>
</div>
my directive and controller:
(function() {
'use strict';
var app = angular.module('quickPreview');
app.controller('globalCtrl', function ($scope) {
// var e = angular.element($("[ng-init]"));
// console.log(e);
// $scope.product = e.attr('ng-init');
// console.log($scope.product);
$scope.product = [];
var logSomeStuff = function(){
console.log($scope.product);
}
$scope.$evalAsync(logSomeStuff);
});
}(window, window.angular));
(function (){
"use strict";
var app = angular.module('quickPreview');
app.directive('previewProduct', function ($compile,$templateCache) {
return {
restrict: 'A',
replace: false,
transclude: false,
scope: {
attrData: '=dataOverview'
},
link: function(scope, element, attrs) {
element.bind('click', '.sd-click-preview', function (){
var preview = angular.element($templateCache.get('quickpreview.html'));
var cpreview = $compile(preview);
element.append(preview);
cpreview(scope);
console.log(cpreview(scope))
if (scope.attrData) {
console.log(this, '=> this');
}
});
}
};
});
}(window, window.angular));
You don't need quotes in ng-init statement. You are ending the statement prematurely.
<li ng-init="product= {brand:'Nike', price:'30€', mainImage:'images/images.jpg'}">
<div class="content-product">
<div class=" product ">
<p>{{product.brand}}</p>
<img ng-src="{{product.mainImage}} " alt=" ">
<p>{{product.price}}</p>
</div>
</div>
</li>
Here's a working example:http://plnkr.co/edit/XRyYefxncZuqE5GeA3XG?p=preview