Giter Club home page Giter Club logo

viajs's Introduction

ViaJS Image

Via is a small library that allows you to load content on to a page dynamically

Demo

ViaJS Demo (click me)

Installing

This library requires jQuery

git clone https://github.com/abdi0987/ViaJS.git

Link to the app.js file

<script src='lib/app.js'></script>

Usage

ViaJS Image

Example

Specifiy were to load the content

<div class="container">
    <div id="title" via-views>Should stay hidden</div>

    <div id="content" via-views>Should stay hidden</div>
</div>

add via-views attribute to your div element to specify where to load the content

Specify your views url and a default view if the user enters an invalid hashtag url.

Then call the init function and pass it your views

var views = {
    home: [{
            selector: "#title",
            templateUrl: 'views/index-title.html'
        }, {
            selector: "#content",
            templateUrl: 'views/index-content.html'
        },
    ],
    about: [{
            selector: "#title",
            templateUrl: 'views/about-title.html'
        }, {
            selector: "#content",
            templateUrl: 'views/about-content.html'
        },
    ],
    contact: [{
            selector: "#title",
            templateUrl: 'views/contact-title.html'
        // }, {
        //     selector: "#content",
        //     templateUrl: 'views/contact-content.php'
        },
    ],
    defaultView: {
        view: 'home'
    }
};

var via = new Via();

via.init(views);

now you can use the short version:

new Via(views);

and also

Then use an a tag

<ul class="nav navbar-nav">
    <li class=""><a via-href="home">Home</a></li>
    <li><a via-href="about">About</a></li>
    <li><a via-href="contact">Contact</a></li>
</ul>

Add __via-href attribute to every tag you are using to load your content and remeber that via-href value should be the same name you gave the views object.

viajs's People

Contributors

abdi0987 avatar thesunlover avatar abdi42 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.