What do I need to do to fix the error in this piece of code? - debugging

<div className="badge-container grow">
<a
href="https://buildspace.so/builds/ai-writer"
target="_blank"
rel="noreferrer"
>
<div className="badge">
<Image src={buildspaceLogo} alt="buildspace logo" />
<p>build with buildspace</p>
</div>
</a>
</div>
);
};
export default Home;
It keeps telling me there is an error with the line of code. I don't know how to fix it.

Related

image-preview.html file in Magento 2 Ui component

I have noticed image-preview.html resides in (view->adminhtml->web->template) in magento 2 module. But i don't understand the code that are referenced within this html file. Here is the source of the image-preview.html file.
`
<div class="file-uploader-preview">
<a attr="href: $parent.getFilePreview($file)" target="_blank">
<img
class="preview-image"
tabindex="0"
event="load: $parent.onPreviewLoad.bind($parent)"
attr="
src: $parent.getFilePreview($file),
alt: $file.name">
</a>
<div class="actions">
<button
type="button"
class="action-remove"
data-role="delete-button"
attr="title: $t('Delete image')"
click="$parent.removeFile.bind($parent, $file)">
<span translate="'Delete image'"/>
</button>
</div>
</div>
<div class="file-uploader-filename" text="$file.name"/>
<div class="file-uploader-meta">
<text args="$file.previewWidth"/>x<text
args="$file.previewHeight"/>
</div>
`
Can someone explain this code to me, else provide what i need to learn to understand and modify this code in my custom magento 2 module as per my requirement.

Collapse using Transition Vue

I would like to use Vue's collapse in my code, but I have an error.
[Vue warn]: <transition-group> children must be keyed: <p>
My component:
<template xmlns:v-model="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<section style="background-color: #dedede;">
<div class="container-fluid">
<div class="Consult-faq container">
<div class="row">
<div class="col-sm-12">
<h2>Cursos</h2>
<a v-for="(course,id) in courses" v-on:click="course.show = !course.show">
<a v-on:click="show = !show">
<div class="col-xs-12" style="border-bottom: solid;border-bottom-color: #999999;border-bottom-width:1px ">
<div class="col-xs-12">
<h4>
<i v-if="course.show" class="fa fa-plus-square text-right" aria-hidden="true"/>
<i v-else class="fa fa-minus-square text-right" aria-hidden="true"/>
{{course.text}}
</h4>
</div>
</div>
<transition-group name="fade">
<p v-if="show">
<div class="col-xs-12">
<article v-for="n in 2" class="Module-content">
<div class=" col-sm-12 col-md-6" style="position: relative;">
<div v-for="(course, index) in course.courses">
<course-card v-if="index % 2 == n - 1" :course="course"></course-card>
</div>
</div>
</article>
</div>
</p>
</transition-group>
</a>
</a>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
export default{
props : [
'courses'
],
data(){
return {
show: false
}
},
mounted() {
console.log(this.courses)
}
}
</script>
So, I'd like to know to collapse item per item. Like this in image.
When I click to expand, all courses expand or close all courses close.
Transition is irrelevant here (though you can get rid of that warning by using transition instead of transition-group, because the transition is only acting on a single node, not a group.)
Right now you're depending on a single variable show to control all of the elements' visibility, so they will all respond to clicks on any of them:
<a v-on:click="show = !show">
<p v-if="show" >
You need individual variables for each element if you want them to expand/collapse separately. You partially did this already, just change the remaining instances of show with course.show and you should be good to go.
(Probably want to clean up that nested <a> within <a> while you're at it; you can just remove the inner one.)
I solved this using vue-resource, I was using Guzzle in Laravel and require data in Controller make this not reactive. And I solved this problem using vue-resource in component.

Fancy box will not work

here is my codepen:
`
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
<div class="container">
<div class="row">
<div class="col-sm-9" id="mainContent">
<a class="fancybox" rel="group" href="img/1.jpg"><img src="img/1a.jpg" alt="" /></a>
<a class="fancybox" rel="group" href="img/me2.jpg"><img src="img/me3.jpg" alt="" /></a>
</div>
</div>
</div>
`
http://codepen.io/anon/pen/gMbmzZ
I can't get this fancy box to work for the life of me. I have checked the file path for the css and the javascript and those should be good. I have also made sure to import jquery into my html file.
no matter what i do i can't get it to work. any help is appreicated.

How to override default odoo 8 website header section

I am trying to override default header section of odoo 8 website with my own design but am getting errors when i use xpath expression and do a replace. See code below :
header.xml code
<template id="layout_replace_menu_header" customize_show="True" inherit_id="website.layout" name="custom_header_replace">
<xpath expr="//div[#class='navbar navbar-default navbar-static-top']" position="replace">
<header>
<div class="header">
<div class="container">
<a class="site-logo" href="#"><img src="/themeotb2/static/otbassets/img/logo.png" alt="image" /></a>
<i class="fa fa-bars"></i>
<!-- BEGIN NAVIGATION -->
<div class="header-navigation pull-right font-transform-inherit">
<ul>
<t t-foreach="website.menu_id.child_id" t-as="submenu">
<li class="dropdown">
<t t-call="website.submenu"/>
</li>
</t>
<!-- BEGIN TOP SEARCH -->
<li class="menu-search">
<span class="sep"></span>
<i class="fa fa-search search-btn"></i>
<div class="search-box">
<form action="#">
<div class="input-group">
<input type="text" placeholder="Search" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-primary" type="submit">Search</button>
</span>
</div>
</form>
</div>
</li>
<!-- END TOP SEARCH -->
</ul>
</div>
<!-- END NAVIGATION -->
</div>
</div>
</header>
</xpath>
</template>
When i use "inside" instead of replace the code will execute but when i do replace odoo complains with errors:
File "/opt/openerp/ttfa/projectdatabase/src/openerp/models.py", line 1270, in _validate_fields
raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition
Error details:
Element '<xpath expr="//header//a[#class='navbar-brand']">' cannot be located in parent view
Error context:
View `Show Logo`
How can i solve this? Thank you.
Either You have to override template "layout_logo_show" or disable "Show Logo" from website Customize setting.
Thank You!

kendo: Enable / Disable button in navigation bar

Below is a definition of the navigation bar, part of a view template that is used among several screens:
<div data-role="layout" data-id="app">
<header data-role="header">
<div data-role="navbar">
<a class="nav-button" data-align="left" data-role="backbutton">Back</a>
<span data-role="view-title">Title</span>
<a class="nav-button" data-align="right" data-role="button" data-click="doneTapped" id="btnDone">Done</a>
</div>
</header>
</div>
The "Done" button is only needed on some screens, so it gets hidden when the main page loads:
$("#btnDone").hide();
Hiding the button works fine, but showing it again does not work:
$("#btnDone").show();
The button does not show up.
Instead of using $("#btnDone").hide(); and $("#btnDone").show(); use:
Hide button:
$("#btnDone").css("visibility", "hidden");
Show button:
$("#btnDone").css("visibility", "visible");
Something that has worked for me in this situation is to put a class on the button I want to show/hide instead of relying on the id:
<div data-role="layout" data-id="app">
<header data-role="header">
<div data-role="navbar">
<a class="nav-button" data-align="left" data-role="backbutton">Back</a>
<span data-role="view-title">Title</span>
<a class="nav-button btnDone" data-align="right" data-role="button" data-click="doneTapped" id="btnDone">Done</a>
</div>
</header>
</div>
And then use the class to hide it:
$(".btnDone").hide();
Hope this works for you as well.
Salam,
Try the following:
<!--Home-->
<div id="tabstrip-home"
data-role="view"
data-init="app.home"
data-title="Home">
<!--Header-->
<header data-role="header">
<div data-role="navbar">
<a class="nav-button" data-align="left" data-role="backbutton">Back</a>
<span data-role="view-title">Title</span>
<a class="nav-button" data-align="right" data-role="button" data-click="doneTapped" id="btnDone">Done</a>
</div>
</header>
<!--Content-->
<div class="view-content">
<h1>Hide / Show Navbar Elements</h1>
<p>
<center>
<a data-align="left" data-role="button" data-click="app.show">Show</a>
</center>
<br />
<center>
<a data-align="left" data-role="button" data-click="app.hide">Hide</a>
</center>
</p>
</div>
</div>
In the data-init="app.home" function you find the navbar, then the leftElement and have references to them then you can control it, Example:
var navbar = null;
var left = null;
global.app.home = function (e) {
navbar = e.sender.header.find('div[data-role="navbar"]').data('kendoMobileNavBar');
left = navbar.leftElement;
console.log(left);
};
global.app.show = function (e) {
left.show();
};
global.app.hide = function (e) {
left.hide();
};
Please see a working example here: http://jsbin.com/EpInoQOq/1/edit
Regards
The way I handled hiding and shwowing the Back Button on different views was to use 2 different Layouts. This worked well for my use case as I only show the back button on 1 page:
<!--Default Layout with Main Menu and no backbutton-->
<div data-role="layout" data-id="layout">
<!--Header-->
<div data-role="header">
<div data-role="navbar">
<span data-role="view-title"></span>
</div>
</div>
<!--Footer-->
<div data-role="footer">
<div data-role="tabstrip">
....
</div>
</div>
</div>
<!--Layout with Back Button-->
<div data-role="layout" data-id="layoutBackButton">
<div data-role="header">
<div data-role="navbar">
<a data-role="backbutton" data-align="left">
<!-- data-bind="isVisible: showBackButton" -->
<i class="fa fa-chevron-left fa-lg"></i>
</a>
<span data-role="view-title"></span>
</div>
</div>
</div>
My Remote View that uses the Back button then specifies the other Layout:
<div data-layout="layoutBackButton"
data-role="view"
...>

Resources