2

i want call view from view. I guess that's possible but i don't know way to do that. I try something like this:

     <button id="submit-buttons" action="<?php  $this->load->view('some_view'); ?>​"​​​​​>Submit 1</button>

and doesn't work. Anyone have some idea?

1
  • and where do you want to call view? in a div inside view or popup etc. Commented Nov 20, 2013 at 11:51

2 Answers 2

3

You can simply do it like this using jquery

View

<div id="result"></div> 
<button id="submit-buttons" href="#"​​​​​>Submit 1</button> 

Also note button does not have action attribute

JQuery

$(function(){
    $('#submit-buttons').click(function(){
        $( "#result" ).load( "<?php echo site_url('controllername/methodname')?>" );
    })
})

Controller

function methodname(){
    $this->load->view('abc.php')
}

View will be loaded inside div having id result

Sign up to request clarification or add additional context in comments.

Comments

1

You working on MVC structure.So you should follow structure properly: Your action should be a controller.From that you can call view.. Example:

<form method="" action="<?php  echo base_url(); ?>​controller_name/function_name">
       <button id="submit-buttons" type="submit" ​​​​​>Submit 1</button>
</form>

Controller:

function functionname(){
    $this->load->view('some_view')
}

1 Comment

he is working in button not form element. Button does not have action attribute

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.